Guest User

Untitled

a guest
Oct 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /* Lets stay simple, we will consider you are storing your
  2. binary sequence in a char[20] for example */
  3.  
  4. int main(void) {
  5. sendToProcess(PID, 12);
  6. }
  7.  
  8. void sendBinarySequence(sequence, PID) {
  9. loop through sequence {
  10. /* The best way here is to always send 4 bytes, increment a value so
  11. the process A don't have to tell you when the sending is done
  12. */
  13. if (bit == 1)
  14. kill(PID, SIGUSR1);
  15. else if (but == 0)
  16. kill(PID, SIGUSR2);
  17. /* Wait for the signal of the process A, we are using ping-pong
  18. */
  19. }
  20. }
  21.  
  22. void sendToProcess(PID, NB_TO_SEND) {
  23. // Send 85 to the process
  24. char binary[20];
  25.  
  26. convertNbToBinary(&binary[0], 85); /* This is the first integrer we
  27. will send, then the process A will know we will send integrer. */
  28. sendBinarySequence(binary, PID);
  29. }
Add Comment
Please, Sign In to add comment