My high priority task is being preempted

I am having an issue where my highest priority task is being preempted by someone (I assuming the kernel) but I don’t know why or how to find out who is doing and why they are doing it. I run a high priority task every 5 ms and I have check to make sure I am not 1.5 time greater in time then my 5 ms update from the last time I ran. I am seeing spots where my high priority task is not running and the time can vary from 15 ms upto 160 ms.
I can’t pinpoint a peridoic time frame when this happens.
I create a ram disk on boot which copies my programs from an ide mounted flash disk. I still write randomly to the flash disk for logs and such but I am not writting that much, maybe a line per second; but I am seeing that when I switch this flash card the problem can worsen.

I would like to find out how I can tell what qnx is doing when it won’t allow my highest priority task to run.

Any suggestions or help?


I haven’t worked with it myself, but this is something that the instrumented kernel should be able to help with.
When you say that you rn a high priority task every 5ms, what exactly do you mean.
are you doing something like this:
sleep 5ms

or are you using an interrupt to wake up every 5ms, or something else?

What is the time slice you are using? If for example, you ask to sleep 5ms, but the timer interrupt
occurs only once every 10ms, you will not get the resolution you expect.
Nothing I can think of should delay you 160ms.


How high is your highest priority task? Without knowing that it’s impossible to speculate.

One quick thing. Are you running Photon? Every once in a while Photon does some graphics work in the background which eats up some CPU time which could cause some delays.

In a similar vein, you might be experiencing the same problem if you have or are doing any network stuff.

There was a thread on here a few months ago about this same thing and I can’t remember now exactly what was the culprit (photon or a network issue)


Tim, I think I recall the incident. Someone was putting out a message across the network that I think was being read off of a scope from a parallel port. The jitter was pretty wild. In the end it did turn out to be something with a graphics card.

I am not running photon.
My highest priority task is 22. It msgPulses some other tasks but I made sure make the pulse prio less then my high priority task. There are no msgsends anymore so I am not getting reply blocked or anything.

My task is creating a timer with qnx and doing a msgreceive on it.

I have attempted to find the amount of time it takes for my task to run by doing a time substraction from the start to the end of the code block for the timer tick receive. It appears to average around 1 ms.

I am not the full orginator of the code nor do I know every corner so there could be interrupts being serviced. There are typically three serial devices in communication with it and four pc104 (isa) cards but the isa cards are not interrupt driven.

Is there a good place to start in getting the instrumented kernel with instructions?


I just took a look at my system priorities here using the ‘pidin’ command.

I noticed that my serial driver (devc-ser8250) is running at priority 24.

You might want to see what yours runs at since you are likely using that driver and you said you had 3 serial devices.

As a simple test, try upping your priority to 25 (1 more than the driver) and see if that proves your timing problems are related to the serial driver.


Is the pulse use for the timer set to high priority. Setting the process priority is somewhat irrelevent, it’s the priority of the event received that mattters.

Just use the System Profiler to find out whats happening

Ok, I am back. I got pulled away for a few days. Where do I find the System Profiler? Is it already in the standard Qnx distro?

My timer pulses are set the priority of the current task’s priority and the pulses going to other tasks are current task’s priority minus 2 or some other number but always lower then my high priority task.

I am about to test the theory of setting my tasks prio higher then the serial driver and I will let you know what happens.

Setting my task to a higher priority then my serial driver doesn’t resolve my problem. I am looking into getting and running the System Profiler but it does require the full development qnx suite and I currently don’t run that on my target machines. Thanks for the insights thus far, I am learning a lot.

You don’t need the full development kit, you can use tracelogger and traceprint. Of course the output of traceprint is all text and will required more work to decipher ;-)

traceprint doesn’t show up on my system and tracelogger creates some file with ‘#’ after it that has size but vim says it isn’t a file.

I have traceprinter. Maybe a typo above or qnx switched the command. That is cool; now to understand it.
I seem to have the tracelogger on my target machine but no log file is being generated. Does this mean I don’t have the instrumented kernel on my target machine? There is no error being returned to me, just no file. I use a different hard drive and see if I can still get my problem to occur and get a tracelogger.
Thanks thus far.


The log file by default is written to /dev/shmem. Are you looking there for it? That is a Ram drive by the way. So if you reboot the file will be lost so you need to collect it before rebooting.

Also, I was re-reading your initial report. You mentioned that periodically, you write to the flash drive in your system. That’s a VERY slow process since flash drives are orders of magnitude slower than harddrives. If you turn off that writing to the flash drive I’d be curious to know if the problem goes away.


Lookup the documentation on traceprinter and tracelogger it’s well explained.

You’re really going to want to load that logfile into the System Profiler - it’s part of the Momentics IDE.

As for how to run tracelogger, assuming 6.3.0SP3 or 6.3.2, then

tracelogger -n0 -v -s5 -w

Make sure you run tracelogger at a high priority…

Quick question:

I got a tracelogger file that should of caught my problem. IT IS ALOT OF DATA!!! Is there any nice gui application that can visualize this data for me? I am currently working through it in a text editor and switching pid numbers to task names so it makes more sense to my eyes. Also the time is in clock cycles. Is this from my processor speed or the programmable qnx clock resolution?


Ahh, I just posted a message that is outdate, the forum went to another page and I didn’t notice that. Sorry.

I have tried replacing my flash disk with a harddrive, I get the same problem. I don’t get the problem when I running on my development box which is a Pentium Xeon something but my target machines are Pentium 1ghz M’s. I also get more problems reported when I switch compact flash disks (I currently use a WinSystem’s Industrial CF but I tried a new Kingston Elite Pro and I get more problems reported even though the Kingston has the same specs as the WinSystem’s).

Thanks cburgess for letting me know I can copy and load that file into my development box’s System Profiler IDE.