Note that there are some explanatory texts on larger screens.

plurals
  1. POSignal Queue Problems (I think)
    text
    copied!<p>I am very new to using signals and handlers. My assignment is to create a scheduler program. When some basic program I made first runs, it sends a signal to the scheduler so that it is added to the scheduler's queue. The program then stops itself and only the scheduler can start/stop it from now on. I'm using sigqueue with SIGRTMIN because I was told these allow signals to be queued. This is important because the scheduler must give time slices to the programs based on the order that they requested to be added to the scheduler's list. I think my programs work fine except when I create more than 2 of the basic type programs at once. I'm guessing that too many signals are being sent to the scheduler at the same time and this is causing strange problems (even though the signals are supposed to be queued...) This is evident because when viewing the programs run, they are running entirely out of order (seemingly random like program 2,3,1,3,2 for example) although the same order repeats every time...</p> <p>Here is some code from my scheduler program.</p> <pre><code>//setting up sigaction struct sigaction sigact; sigemptyset(&amp;sigact.sa_mask); sigaddset(&amp;sigact.sa_mask, SIGRTMIN); sigact.sa_flags = SA_SIGINFO; sigact.sa_sigaction = sigHandler; sigaction(SIGRTMIN, &amp;sigact, NULL); //the actual signal handler function void sigHandler(int sigNum, siginfo_t *info, void *unused) { if (sigNum == SIGRTMIN) { pid_t nextWorker = info-&gt;si_pid; insert_pid(&amp;pid_q, nextWorker); fprintf(stdout, "PID: %d added to queue.\n", nextWorker); fflush(stdout); } } </code></pre> <p>Please help me find out what is happening! :)</p>
 

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