| | |
semaphores
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Apr 2008
Posts: 3
Reputation:
Solved Threads: 0
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.
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.
python Syntax (Toggle Plain Text)
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
![]() |
Other Threads in the Computer Science Forum
- Previous Thread: Pentium
- Next Thread: got a few homework questions
| Thread Tools | Search this Thread |
ai algorithm algorithms amazon assignment assignments automata battery bigbrother binary bizarre bletchleypark blogging bomb business cern codebreaker compiler computer computers computerscience computertrackingsoftware connect conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationthesis dissertationtopic ebook energy extensions floatingpoint foreclosure foreclosuresoftware fuel gadgets geeks givemetehcodez government graphics hardware history homeowners homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod itcontracts jobs kindle laser laws linkbait lsmeans mainframes mining mobileapplication msaccess nano netbeans news os p2p piracy piratebay principles programming rasterizer research sam-being-cute sas science security sex simulation software spying sql stephenfry study supercomputer sweden technology textfield turing turingtest two'scompliment virus warehouse ww2






