LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2008, 04:23 AM   #1
papunb
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Rep: Reputation: 0
How to make a (user space )process pre emptive? in 2.6 kernel


Hi!
I am writing a program which i dont want the kernel scheduler to preempt before certain time duration. I am using the system call sched_get_priority_max to set the maximum priority. However it is not producing results.
Waiting for some suggestions.

Mnka
 
Old 12-10-2008, 02:07 PM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
'sched_get_priority_max' does not set any values. You need to use 'sched_setparam'.
 
Old 12-11-2008, 04:24 AM   #3
papunb
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Thanks for the reply.
Even if i use sched_setparam , i can utmost set the schedule policy and the max priority for that policy , but if i am using SCHED_FIFO and suppose there is another process using SCHED_RR, my process may be pre empted for the SCHED_RR running process.. How do i ensure that for a given time slice , my process is not preemted.
 
Old 12-11-2008, 07:11 AM   #4
papunb
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Original Poster
Rep: Reputation: 0
The following is what i am trying to do but i am not able to change the priority of the scheduler .. I am only able to change the policy using sched_setscheduler. I have running it in SU.

int sched_setpriority(pid_t pid, int priority)
{
struct sched_param p;
int min_pri, range_pri;
p.sched_priority = priority;
return sched_setscheduler(pid, SCHED_FIFO, &p);
}



int sched_getsched(pid_t pid)
{
return sched_getscheduler(pid);
}

int sched_getpriority(pid_t pid)
{
return getpriority(PRIO_PROCESS, pid);
}

int main ()
{
pid_t proc ;
proc = getpid();
int i, j, s;
i = sched_getsched(proc);
j = sched_getpriority(proc);

printf("My current sched is %d\nMy current pri is %d\n\n", i, j);

s = sched_setpriority(proc, 99);
if(s)
{
perror("Set Priority -- \n");
}

i = sched_getsched(proc);
j = sched_getpriority(proc);
printf("My new sched is %d\nMy new pri is %d\n\n", i, j);

}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send events from kernel module to user space process yugandhar Linux - Kernel 2 02-21-2011 10:39 AM
How to access device from user space process stardust496 Linux - Hardware 3 07-23-2008 01:40 PM
pre emptive strike for Gdive log Greebstreebling Linux - Software 0 09-15-2007 10:35 AM
Pre-emptive vs. Non-pre-emptive kernel jhwilliams Linux - General 7 09-05-2007 09:06 PM
Installation Advice - pre-emptive Walton SUSE / openSUSE 7 08-19-2007 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration