Note that there are some explanatory texts on larger screens.

plurals
  1. POSleeping process doesn't respond to signals
    primarykey
    data
    text
    <p>I've got a program where main process forks into 4 children that cooperate with each other:</p> <p>process0 is opening FIFO file (O_WRONLY), reading 1 byte at a time from STDIN using read function, writing into FIFO using write and closing FIFO file</p> <p>process1 is waiting for the shared memory to be empty (I'm using first byte of shared memory table if(tab[0] == 0) to check if its empty) opening FIFO file (O_RDONLY), reading from it, translating this one byte into hex and saving it into shared memory. It then closes fifo and sets tab[0] which is shared memory table to 1. </p> <p>process2 is reading from shared memory if tab[0] == 1. After reading it writes data into pipe</p> <p>process3 is reading from pipe and writing into STDIN</p> <p>this all works perfect. The problem started when I wanted to add signals. I'm using semaphores to synchronize p0 and p1, signals to synchronize p1 and p2 and message queue to synchronize p2 and p3. It also works fine except for the times when for example process1 is in the sleeping mode. It goes into this mode when it wants to read from fifo and has to wait for data to be transferred.. I guess. I've been reading about it. </p> <p><a href="http://imageshack.us/a/img853/6655/asdasdasdcf.jpg" rel="nofollow">processes hierarchy</a></p> <p>Here's what I've found that I think may be the cause:</p> <p>"When the process makes a system call while in user mode (1), it moves into state 2 where it begins to run in kernel mode. Assume at this point that the system call made was to read a file on the hard disk. Because the read is not carried out immediately, the process goes to sleep, waiting on the event that the system has read the disk and the data is ready. It is now in state 4. When the data is ready, the process is awakened. This does not mean it runs immediately, but rather it is once again ready to run in main memory (3). "</p> <p>I think I understand it but how can I avoid this? I want my program to react to signals always. Is there some way to change processes state from sleeping to running when I send the signal through "kill" ? Can I somehow tell the process to stop "waiting on the event that the system has read the disk and the data is ready" ?</p> <p>here's my code if someone wants to look at it:</p> <p><a href="http://pastebin.com/DdfnSSju" rel="nofollow">Program's code</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload