Re: Two real time tasks?

Brandon Rutter <[email protected]> Fri, 11 Feb 2005 15:13:05 +0100
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
To get the faster task to pre-empt the slower one, you need to set the 
priorities appropriately by doing something like:

         pthread_attr_t attr;
         struct sched_param sched_param;
         int maxpri = sched_get_priority_max(SCHED_FIFO);
         pthread_t fast, slow;

         sched_param.sched_priority = maxpri;
         pthread_attr_setschedparam (&attr, &sched_param);
         pthread_create (&fast,  &attr, fast_thread_code, NULL);

         sched_param.sched_priority = maxpri-1;
         pthread_attr_setschedparam (&attr, &sched_param);
         pthread_create (&slow,  &attr, slow_thread_code, NULL);

Hope this helps,
Brandon Rutter


On Feb 10, 2005, at 7:47 PM, Chris Smolinski wrote:

> I have a question concerning running two real time tasks at once. I've 
> created two such tasks, one running every 250 microseconds, and one 
> every 10 millieconds. For testing purposes, I have each test turn a 
> parallel port line on when the task starts to run, and off just before 
> it goes back to sleep. Viewing the two outputs on a scope, everything 
> looks fine.
>
> But, if the slower task takes longer than 250 microseconds to run 
> (actually the problem happens before then), it is not pre-empted to 
> allow the faster task to run. Instead, once it is done, the faster 
> task runs, and then the next instance of the faster task runs earlier, 
> presumably so that the average execution rate remains 250 
> microseconds.
>
> Is there anything I can do to have execution of the slower task halted 
> to allow the faster task to run at the correct time, and then return 
> to the slower task when the faster task is finished?
>
> -- 
>
> ---
> Chris Smolinski
> Black Cat Systems
> http://www.blackcatsystems.com
> _______________________________________________
> Rtl mailing list
> [email protected]
> http://www2.fsmlabs.com/mailman/listinfo/rtl
>

_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl