Alarm / timer callback from the kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I’m porting several huge libraries from other real-time os'es (VxWorks, WINCE, 
DSP/BIOS etc.) to Linux. The job includes porting of a glue-layer between 
Linux and the libraries. This glue-layer is the implementation of:
* clock_ms ()
* int_lock()
* int_unlock()
* mutex_create()
* mutex_give()
* task_create()
etc.
etc.

Each function has a different implementation on each real-time os.

As an ex. the implementation of mutex_create() for vxworks is like this:
SEM_ID id = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
	
while on Linux it is like this:

sem_t *semH = (sem_t*)malloc( sizeof(sem_t) );
sem_init(semH, 0,init); 
return (void*)semH;

By using this approach, the libraries can be written independent of OS.

But the functions (which I need) that causes problem for me is the following 
functions:

timer_init( callbackFunc )
and
timer_set( CLOCK_MS timeMs )

The first function (timer_init) is called at startup of my application, and 
installs a callbackfuction for all timerevents. The second function is to arm 
the timer. When the timer goes off, the callbackfuntion should be called 
preferably on a high priority. Some of the other os'es implements this as a 
one-shot-timerinterrupt, so the priority should be quite high.

My first approach to port this to Linux was to use signals and setitimer(). 
This worked, but the problem with this solution was that the priority of the 
callback was the same as the priority of the thread that set up the timer.

My next approach was to use a special high priority timer thread. Whenever a 
lo-pri thread needs to arm the timer, it signals the high-pri thread to set up 
the alarm. I have not tested this yet so I don't know how well it will work.

But does other have other solutions/suggestions how to solve this?

br. Morten


-
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux