was hoping someone could help me with semaphores...im a little confused

heres the question:

There are three kinds of processes in a system: type A, type B and type C. There are
many processes of types A and B, but only one process of type C. The type C process
cannot begin its task (Task_C()) until n processes of type A or m processes of type B
finish their respective tasks. More specifically, the type C process must block itself until
enough processes of type A or type B complete their tasks. Write synchronization code
for the three types of processes using semaphores. Use the templates below for each
process type. Hint: You’ll also want to use integer counts.

crosspost

a = b = 0 # shared counters
sem(0)    # semaphore initialized to 0

func_A:   # code for type A process
    a = a + 1
    sem.V

func_B:   # code for type B process
    b = b + 1
    sem.V

func_C:   # code for type C process
    while (a < n && b < m):
        sem.P
    # critical section
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.