-
High priority task
Hi,
i need to write a programm which checks every milisecond for new data through an ioport.
In the meantime it has to do some calculations, but getting the data MUST have priority.
I tried it with setitimer() and ITIMER_VIRTUAL calling every milisecond a sighandler function, but this fails.
/edit : the function gets called but sometimes after more than a miliseconda
So i wanted to ask whether there could be a better way to do this. The programm runs using root rights
Thanks
-
What kind of ioport? If you have a descriptor associated with it then you can use select() or poll().
-
Doing anything with repeatable 1-ms accuracy in a desktop operating system is pretty near impossible. There's simply too many things going on which can interfere with your timings.
> So i wanted to ask whether there could be a better way to do this
The better (but very involved) way is to write a kernel level driver for your port, which can react rapidly to servicing the port, and store the data until your program is ready to read it.
-
The programm will not run under a desktop system.
It will run on an embedded Linux, which basically, beside system tasks, runs this programm alone.
I directly access the ports at the moment via inw() and outw(), the PCI Card has no Interrupt capabilty.
-
> The programm will not run under a desktop system.
See - this is critical information in my book.
Are there other things you're not saying?
Like what PCI card you have for example.
This is one hell of a jump from your previous question.
-
Sorry not to mention that before.
Well the PCI Card is a self developed one with a Lattice Chip for PCI Communications.
The embedded linux is from IES and based on SuSE 9.2 Kernel, the hardware is basically a i386 in µATX format.
Thanks anyway.
-
> the PCI Card has no Interrupt capabilty.
An important omission on your part then.
I still think a driver is the best approach, but instead of using card interrupts it uses a fast clock on the motherboard instead to trigger polling of the card.
-
Yeah, Salem is right, if you want the most accurate timing, you need to write a kernel driver, that deals with the times instead, then it can call tasklet. But to change a user process's priority, look into nice.
-
Thank you very much.
I decided to code a kernelmodul.