Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-20-2004, 08:53 PM   #1
LQ Newbie
Registered: Jul 2004
Posts: 9

Rep: Reputation: 0
Question Changing Process Priority in Linux w/ System Call

I'm trying to get the Linux scheduler to change the priority of a process for a certain number of timeslices by adding a system call to sched.c. I want to then later be able to pass a process pid parameter to that sys call in another *.c and change its priority for a certain # of timeslices. So given a struct task_struct with my process in it, can anyone show me any concrete example code on how I can actually change the priority of that process and only for a certain # of timeslices? I've looked on the 'net and can only find abstract ideas and procedures but nothing to aid me in actual coding.
Old 07-21-2004, 05:23 AM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
In what way is it different from calling nice(2) or setpriority(2) for a certain amount of time?
Old 07-21-2004, 09:58 AM   #3
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Hko is saying there are two system calls nice() and setpriority()

I have no idea how to figure out the size of quanta (time slices) or how many have elapsed for a process without getting into the kernel.

Plus, if you want to use nice to make priority lower, you have to run privileged.

Unless you are in a realtime system, you are better off letting the scheduler figure it out for you. If you do something dumb in code and have the priority set, you can make the system unusable.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 write a system call to display the process information? Programming 3 09-30-2005 01:05 AM
When does process swap happen in a system call? oldfogie Programming 3 05-03-2005 07:35 PM
Changing the fork system call seshuch Programming 0 10-02-2004 05:18 AM
is there a system call to send process to run in the background? feetyouwell Programming 4 10-01-2004 04:58 AM
Changing priority of Dual Boot System LinuxVirgIan Linux - Newbie 5 07-02-2004 05:45 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:00 AM.

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