Share your knowledge at the LQ Wiki.
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 05-04-2005, 03:40 PM   #1
LQ Newbie
Registered: May 2005
Posts: 4

Rep: Reputation: 0
Real-time Round-Robin Scheduling

Is any one know how to set the scheduling timeslice (quantum) of a thread runing in the real-time round-robin (SCHED_RR) scheduling policy ? I was able to set its scheduling policy & priority via "pthread_setschedparam" API, but not able to find a way to change its timeslice.

Old 05-05-2005, 10:21 AM   #2
bruce ford
Registered: Jul 2004
Location: Munich, Germany
Distribution: Sun Solaris 8, SuSE 9.0
Posts: 43

Rep: Reputation: 15
Posix threads api offers no way to do this. Sorry for this short and frustrating answer...

As far as I know is all you can do is to modify the priority of the process your threads are running in to some higher/lower value.

Old 05-06-2005, 04:41 PM   #3
LQ Newbie
Registered: May 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Yes, one can use 'nice' to modify the priority of a process, which indirectly set a timeslice value for all the real-time round-robin threads belong to that process. The shortfall is each real-time round-robin threads of a process can not have its own timeslice. It would be nice to have extention to the POSIX thread priority scheduling APIs to control timeslice of individual threads.

I did a quick look at 2.6 kernel source linux/kernel/sched.c:

* BASE_TIMESLICE scales user-nice values [ -20 ... 19 ]
* to time slice values.
* The higher a thread's priority, the bigger timeslices
* it gets during one round of execution. But even the lowest
* priority thread gets MIN_TIMESLICE worth of execution time.
* task_timeslice() is the interface that is used by the scheduler.

(MAX_PRIO-1 - (p)->static_prio) / (MAX_USER_PRIO-1)))

static unsigned int task_timeslice(task_t *p)

In function "scheduler_tick", I found the timeslice of the rond-robin thread is re-evaluated as follow:

* RR tasks need a special form of timeslice management.
* FIFO tasks have no timeslices.
if ((p->policy == SCHED_RR) && !--p->time_slice) {
p->time_slice = task_timeslice(p);
p->first_time_slice = 0;

/* put it at the end of the queue: */
dequeue_task(p, rq->active);
enqueue_task(p, rq->active);

seem like somehow if we can access to the thread static_priority, perhaps we can control the timeslice of individual round-robin thread.


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
round robin source code vishamr2000 Linux - Security 3 04-21-2005 07:00 AM
dns round-robin tzkolinux Linux - Networking 1 12-27-2004 03:49 AM
Setting Up DNS Round Robin Longhair Linux - Newbie 0 05-25-2003 12:09 PM
round robin for servers deepagodkhindi Programming 5 05-11-2003 05:50 AM
Round Robin DNS Lucsi Linux - Software 1 07-18-2002 04:17 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration