LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 05-04-2005, 03:40 PM   #1
cttran
LQ Newbie
 
Registered: May 2005
Posts: 4

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


Hi,
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.

Thanks!
 
Old 05-05-2005, 10:21 AM   #2
bruce ford
Member
 
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.

bruce
 
Old 05-06-2005, 04:41 PM   #3
cttran
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.
*/

#define BASE_TIMESLICE(p) (MIN_TIMESLICE + \
((MAX_TIMESLICE - MIN_TIMESLICE) * \
(MAX_PRIO-1 - (p)->static_prio) / (MAX_USER_PRIO-1)))

static unsigned int task_timeslice(task_t *p)
{
return BASE_TIMESLICE(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;
set_tsk_need_resched(p);

/* 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.
 
  


Reply


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


All times are GMT -5. The time now is 11:41 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration