On Sunday 22. March 2009 09.08.45 Chetan Nanda wrote: > Hi All, > > I am experimenting with real time process on kernel version 2.6.24 (under > UML) and having root privileges. > I have written a simple code as follow: > > /*##############################*/ > int main() > { > pid_t pid; > struct sched_param param; > pid = getpid(); > memset((void *)¶m, 0 , sizeof(struct sched_param)); > param.sched_priority = 30; > > /*change the priority to rt*/ > sched_setscheduler(pid,SCHED_FIFO, ¶m); > > while(1); very dangerous (and completely pointless). No rt-task should ever do this. If you have a computational intensive task, you should not run that in rt-mode, but as a high-priority userland task. If it also requires polling of some devices at a very precise interval, you should split it. Things that absolutely *must* run as rt-task, in one (or more) processes with rt-pri, the rest as normal tasks. I cannot stress this enough :) The kernel will freeze, and this is intentional - after all, you've just told it to. The computer will continue to function though, because the absolute highest priority is reserved for the kernel, so you can have a kernel thread with slightly higher priority. And you cannot disable interrupts. But, everything else will freeze up. And I will repeat this: because *you* asked it to do so. Running things on rt-level is great. But it places a lot of responsibility on your shoulders. rt-priorities should come with the spiderman-mantra: with great power, comes great responsibility :) > } > /*##############################*/ > > On running this program cause system to hangs and this is as per the real > time task implementation in the kernel. > Which says a rt task with policy equal to 'SCHED_FIFO' will run till it > voluntarily release CPU. Or if a task with even higher priority becomes runnable. > Is there any way to kill such task? Isn't this kind of behavior > compromising system security? Well.. If you have more than one core, you can do it via the shell (as the shell will have much lower priority than 30 :) Then you can kill it like any other task (given you have root-privileges. If you are running this on a single-core setup, you better hope you have another task running with higher priority that can kill the taskf or you once it realizes the rt-tasks is hogging all the cpu. > ~~ > Chetan Nanda Henrik
Attachment:
signature.asc
Description: This is a digitally signed message part.