Can I change QNX's idle process policy?

R. Allen & R. Krten are right about sac. I checked the cpu usage using “sin
ti” and the QNX idle nolonger gets cpu time whereas my idle process does.

Thanks for the good find, I was getting worried about my scheduler.

Previously, Robert Krten wrote in qdn.public.qnx4:

Nope; what Bill said; with a tiny semantic clarification:
If the FIFO is CPU bound it will never be preempted by another process of
the same priority.
(It’s certainly welcome to call Yield() and voluntarily give up CPU to another
process at the same priority, but it’s not obligated).
Period.

The definition of FIFO is “runs until it voluntarily gives up CPU; or a higher
priority process becomes ready”. RR is identical except that it has a max one timeslice
period IF another process is ready at the same prio.

We are in complete agreement about the problem and the
definition of FIFO. Below is a test program that might

answer the question. I adjusted the MAXLOOP parameter
so that a countable macroscopic amount of time will pass
for both processes to complete. On my system this is about
7 seconds. When I run this, about 6 seconds passes, and then
“Parent” is printed. A second later “Child” is printed.
Since both processes start out as RR at the fork(), both
will begin competing for cycles. As soon as parent gets
control it changes to FIFO and it should control the cpu
until completing the for() loop.


Mitchell Schoenbrun --------- maschoen@pobox.com


#include <libc.h>
#include <sys/sched.h>
#include <sys/kernel.h>
#define MAXLOOP 1000000000
pid_t child;
main()
{
qnx_scheduler(PROC_PID,0,SCHED_RR,-1, 0);
child = fork();
if (child == 0)
{
child_process();
}
parent_process();
}
void parent_process()
{
int i;
int a;
int stat_loc;

a = 0;
qnx_scheduler(PROC_PID,0,SCHED_FIFO,-1, 0);
for(i=0;i<MAXLOOP;i++)
{
a += i;
}
fprintf(stderr,“Parent\n”);
wait(&stat_loc);
exit(0);
}
void child_process()
{
int i;
int a;

a = 0;
for(i=0;i<MAXLOOP;i++)
{
a += i;
}
fprintf(stderr,“Child\n”);
exit(0);
}