Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Reply

Join Date: Apr 2008
Posts: 3
Reputation: cppsevennine is an unknown quantity at this point 
Solved Threads: 0
cppsevennine cppsevennine is offline Offline
Newbie Poster

semaphores

 
0
  #1
Apr 9th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: semaphores

 
0
  #2
Apr 9th, 2008
crosspost
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 15
Reputation: jaux is an unknown quantity at this point 
Solved Threads: 2
jaux's Avatar
jaux jaux is offline Offline
Newbie Poster

Re: semaphores

 
0
  #3
Apr 15th, 2008
  1. a = b = 0 # shared counters
  2. sem(0) # semaphore initialized to 0
  3.  
  4. func_A: # code for type A process
  5. a = a + 1
  6. sem.V
  7.  
  8. func_B: # code for type B process
  9. b = b + 1
  10. sem.V
  11.  
  12. func_C: # code for type C process
  13. while (a < n && b < m):
  14. sem.P
  15. # critical section
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Computer Science Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC