Reputation: 51
i need to set a signal high and low by time in a linux kernel, using, timer and mdelay().
hightime: 0.01ms-20.00ms; lowtime:10ms-1000ms
both are adjustable by userspace. For the lowtime i use an API timer and for the hightime i use mdelay() and udelay().
Now the problem: if hightime is 9.9ms and lowtime is 10ms the kernel is asleep for the whole time (expect 0.1ms). But my userinterface in the userspace needs to work, while the kernel timer is running. One jiffie is about 10ms in my system, so i can not use a timer for the lowtime.
Someone got an idea, how i can do these 0.01ms - 10 ms waits in the kernel, so that my userinterface still works properly?
Thanks
Upvotes: 1
Views: 1173
Reputation: 5194
You can reduce the 10 ms:
Edit /usr/include/asm/param.h
and look for definition of HZ. I guess you'll find 100.
100 Hz presents a period of 10 ms. More modern Linuxes have 250 HZ which would put your time
slice down to 4 ms. You may sqeeze it to 1000 HZ which lets you run at 1 ms slices.
Further reading: Linux kernel map, 7.1. Measuring Time Lapses
Upvotes: 1