Advertisement
Guest User

Untitled

a guest
Mar 7th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.51 KB | None | 0 0
  1. proc P:
  2.     always_loop:
  3.         v = produce()
  4.         remove(availableJob) //If theres no available job, the buffer is full
  5.         post(product, v) //The buffer is no longer empty
  6.        
  7. proc C:
  8.     always_loop:
  9.         remove(product, v) //If there is no product, the buffer is empty
  10.         post(availableJob) //The buffer is no longer full
  11.         consume(v)
  12.  
  13. main:
  14.     n := WhataverBufferCapacityYouMayLike
  15.     for 1...n
  16.         post(availableJob) //Create n jobs for the producer
  17.    
  18.     for 1...numProducers
  19.         run proc P
  20.    
  21.     for 1...numConsumers
  22.         run proc C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement