Consider the following pseudocode for threads that communica…
Consider the following pseudocode for threads that communicate using a linux pipe (message passing). What is the order that the functions (e.g. horse(), cat(), etc) run in? Note that, with Pipes, the receiving operation blocks the thread until the message is received. pipe pipe1 = new Pipe(); pipe pipe2 = new Pipe(); void thread1() { receive_from_pipe(pipe1); zebra(); write_to_pipe(pipe2, “msg1”); receive_from_pipe(pipe1); horse(); waterfall(); write_to_pipe(pipe1, “msg3”); receive_from_pipe(pipe1); } void thread2() { dog(); write_to_pipe(pipe1, “msg2”); receive_from_pipe(pipe2); cat(); write_to_pipe(pipe1, “msg4”); }
Read Details