Advertisement
HasteBin0

simple_pipe_test_gpe_oscillation

Sep 11th, 2020
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/python3
  2. from simple_pipe import *
  3.  
  4. ppc1 = ProcessPairController()
  5. ppc2 = ProcessPairController()
  6.  
  7.  
  8. def p1():
  9.     wait_turn = GeneratePPCExchange.send_oscillate(ppc1, ppc2)
  10.     for i in range(10):
  11.         wait_turn()
  12.         print('Process AAA iteration', i)
  13.  
  14.  
  15. def p2():
  16.     wait_turn = GeneratePPCExchange.receive_oscillate(ppc1, ppc2)
  17.     for i in range(10):
  18.         wait_turn()
  19.         print('Process BBB iteration', i)
  20.  
  21.  
  22. thread1 = Process(target = p1, name = "Process AAA")
  23. thread2 = Process(target = p2, name = "Process BBB")
  24. thread1.start()
  25. thread2.start()
  26. thread1.join()
  27. thread2.join()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement