Sponsored Content
Full Discussion: Scheduling Queues: Help
Top Forums Programming Scheduling Queues: Help Post 302525208 by georgekeishing on Thursday 26th of May 2011 04:53:23 AM
Old 05-26-2011
It's very easy to get lost in the terms people uses it on day today basis, however knowing who and where are they being used is the easiest way of keeping tab on these terms you mentioned.

Here are some of the basic info which I believe , might help you differentiating them. If someone find this information not up to date, your corrections are most welcome. Thanks

Ready Queues / Runqueues

The job of the scheduler is simple: choose the task on the highest priority list to execute and that list which the scheduler refers to is in the runqueue.

The Linux 2.6 scheduler runqueue structure describes that each CPU has a runqueue made up of 140 priority list that are serviced in FIFO order out of which 1-100 are real time task priorities and remaining 101-140 for user task priority.

As the number of queue is fixed (140) and is independent of the number of processes running.

This Queue is a list of task prioity listed as FIFO and per CPU a runqueue is associated with it. Each runqueue has 2 priority queue list "Active and expired runqueue".

In other way, Per Processor -> 2 Runqueue(Active/Expired) -> Each runqueue has an array of 140 priority entries(queues) -> one for each Priority/privilege level

When a task is on the active runqueue, execut in its time slice given by CPU to do the job and if it uses all of its CPU time slice and still not completed,then it's moved to the expired runqueue and its time sclice is recalculated and so does its priority.

If no tasks exist on the active runqueue for a given priority, the pointers for the active and expired runqueues are swapped, thus making the expired priority list the active one. That should atleast give the picture what it is. (If you are going further better have a look at the 2.6 scheduler designed and implemented by Ingo Molnar )

I/O Queue

Although most Linux users are familiar with the role of process schedulers,many users are not so familiar with the role of I/O schedulers. I/O schedulers are similar in some aspects to process schedulers; for instance, both schedule some resource among multiple users. It is well known that Linux implemented four types of I/O schedulers (noop/deadline/anticipatory/cfq) in Linux kernel 2.6.10.

Linux I/O scheduler also has a functionality to sort incoming I/O requests in its request-queue for optimization. Queue size is configurable and you can see the default Queue size in example bellow

Example:
rango@ubuntu:$ cat /sys/block/sda/queue/nr_requests
128

Have a look at the Linux I/O scheduler framework in Linux forums to get the idea where the queues are and how it enqueues and dequeues the I/O request and so on. There is a whole world out there, but this should do the trick at the moment.

Job Queue

Basically, job queues are old mainframe concept literally a queue, or line of people waiting to have their programs run. The generic term is still used now and then ,say cronjob where your program executes in the order you assign or just to give you the literal picture of it ...“Printers” . You can also see Linux provide facility like at, batch so on to queue the job. The internal working of the schedulers is publicity shy and works behind the scene, so its fair enough for this post to assume that your job will get done.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Print Queues

I have a print queue set up with the following options: remote, standard processing, Hostname=(A Windows 2000 Server), bsd print spooler. It takes about 1 minute to transfer a 100 kb file and it times out (downs the queue) on larger files. When tested on a different system at a different location... (2 Replies)
Discussion started by: Scottb7711
2 Replies

2. UNIX for Advanced & Expert Users

at queues

Hi, I submit some processes throught an at queue with the cmd at -q queue. I can easily check the waiting process with atq. But how can I check running processes within a specific queue ? Thanks, Stef (2 Replies)
Discussion started by: stef
2 Replies

3. Linux

print queues

RH 7.2 Are there any commands to check the print queue status? Something along the lines of AIX's "qchk"? Thanks!! (2 Replies)
Discussion started by: jalburger
2 Replies

4. Programming

Message queues

Hi all, I've been trying for hours to figure out how to turn my 2-program (one to send and one to receive) "chat system" using message queues, into a single program where each concurrent component (entity) will both send and receive messages. PLEASE give me a hand with this, I'm starting to... (9 Replies)
Discussion started by: mgchato
9 Replies

5. UNIX for Dummies Questions & Answers

message queues

let 3 processes a, b and c are sharing msgs using msg queues.process 'a' sending msg to 'c' and in turn 'c' send sthat msg to 'b'.if something happens to c how can 'a' and 'b' know that 'c' is not available?????? (2 Replies)
Discussion started by: sukaam
2 Replies

6. BSD

Posix queues

Hi! Everybody%) I got a question like this: Does my FreeBSD5.1 support Posix queues. Thanks! (7 Replies)
Discussion started by: kamazi
7 Replies

7. UNIX for Advanced & Expert Users

message queues

#include <sys/ipc.h> #include <sys/msg.h> int main() { int qid; int t; struct msgbuf mesg; qid=msgget(IPC_PRIVATE,IPC_CREAT); mesg.mtype=1L; mesg.mtext=1; t=msgsnd(qid,&mesg,1,0); printf("%d",t); } the program prints -1 as the result of msgsnd ,which means that msgsnd doesn't... (1 Reply)
Discussion started by: tolkki
1 Replies

8. UNIX for Dummies Questions & Answers

message queues

can any body provide a tutorial that explains the concept of message queues in UNIX in great detail (1 Reply)
Discussion started by: asalman.qazi
1 Replies

9. Shell Programming and Scripting

Cleaning Message Queues

i have an application installed on AIX 5.3 and i have made a script that shutdown a proccesses that exceeded 10000kb of memory usage but i have a problem with cleaning the message queues of these proccesses after shutting them down. Is there any way to clean the message queues for this particular... (8 Replies)
Discussion started by: Portabello
8 Replies
SCHEDULER(9)						   BSD Kernel Developer's Manual					      SCHEDULER(9)

NAME
curpriority_cmp, maybe_resched, resetpriority, roundrobin, roundrobin_interval, sched_setup, schedclock, schedcpu, setrunnable, updatepri -- perform round-robin scheduling of runnable processes SYNOPSIS
#include <sys/param.h> #include <sys/proc.h> int curpriority_cmp(struct proc *p); void maybe_resched(struct thread *td); void propagate_priority(struct proc *p); void resetpriority(struct ksegrp *kg); void roundrobin(void *arg); int roundrobin_interval(void); void sched_setup(void *dummy); void schedclock(struct thread *td); void schedcpu(void *arg); void setrunnable(struct thread *td); void updatepri(struct thread *td); DESCRIPTION
Each process has three different priorities stored in struct proc: p_usrpri, p_nativepri, and p_priority. The p_usrpri member is the user priority of the process calculated from a process' estimated CPU time and nice level. The p_nativepri member is the saved priority used by propagate_priority(). When a process obtains a mutex, its priority is saved in p_nativepri. While it holds the mutex, the process's priority may be bumped by another process that blocks on the mutex. When the process releases the mutex, then its priority is restored to the priority saved in p_nativepri. The p_priority member is the actual priority of the process and is used to determine what runqueue(9) it runs on, for example. The curpriority_cmp() function compares the cached priority of the currently running process with process p. If the currently running process has a higher priority, then it will return a value less than zero. If the current process has a lower priority, then it will return a value greater than zero. If the current process has the same priority as p, then curpriority_cmp() will return zero. The cached priority of the currently running process is updated when a process resumes from tsleep(9) or returns to userland in userret() and is stored in the private variable curpriority. The maybe_resched() function compares the priorities of the current thread and td. If td has a higher priority than the current thread, then a context switch is needed, and KEF_NEEDRESCHED is set. The propagate_priority() looks at the process that owns the mutex p is blocked on. That process's priority is bumped to the priority of p if needed. If the process is currently running, then the function returns. If the process is on a runqueue(9), then the process is moved to the appropriate runqueue(9) for its new priority. If the process is blocked on a mutex, its position in the list of processes blocked on the mutex in question is updated to reflect its new priority. Then, the function repeats the procedure using the process that owns the mutex just encountered. Note that a process's priorities are only bumped to the priority of the original process p, not to the priority of the previously encountered process. The resetpriority() function recomputes the user priority of the ksegrp kg (stored in kg_user_pri) and calls maybe_resched() to force a reschedule of each thread in the group if needed. The roundrobin() function is used as a timeout(9) function to force a reschedule every sched_quantum ticks. The roundrobin_interval() function simply returns the number of clock ticks in between reschedules triggered by roundrobin(). Thus, all it does is return the current value of sched_quantum. The sched_setup() function is a SYSINIT(9) that is called to start the callout driven scheduler functions. It just calls the roundrobin() and schedcpu() functions for the first time. After the initial call, the two functions will propagate themselves by registering their call- out event again at the completion of the respective function. The schedclock() function is called by statclock() to adjust the priority of the currently running thread's ksegrp. It updates the group's estimated CPU time and then adjusts the priority via resetpriority(). The schedcpu() function updates all process priorities. First, it updates statistics that track how long processes have been in various process states. Secondly, it updates the estimated CPU time for the current process such that about 90% of the CPU usage is forgotten in 5 * load average seconds. For example, if the load average is 2.00, then at least 90% of the estimated CPU time for the process should be based on the amount of CPU time the process has had in the last 10 seconds. It then recomputes the priority of the process and moves it to the appropriate runqueue(9) if necessary. Thirdly, it updates the %CPU estimate used by utilities such as ps(1) and top(1) so that 95% of the CPU usage is forgotten in 60 seconds. Once all process priorities have been updated, schedcpu() calls vmmeter() to update various other sta- tistics including the load average. Finally, it schedules itself to run again in hz clock ticks. The setrunnable() function is used to change a process's state to be runnable. The process is placed on a runqueue(9) if needed, and the swapper process is woken up and told to swap the process in if the process is swapped out. If the process has been asleep for at least one run of schedcpu(), then updatepri() is used to adjust the priority of the process. The updatepri() function is used to adjust the priority of a process that has been asleep. It retroactively decays the estimated CPU time of the process for each schedcpu() event that the process was asleep. Finally, it calls resetpriority() to adjust the priority of the process. SEE ALSO
mi_switch(9), runqueue(9), sleepqueue(9), tsleep(9) BUGS
The curpriority variable really should be per-CPU. In addition, maybe_resched() should compare the priority of chk with that of each CPU, and then send an IPI to the processor with the lowest priority to trigger a reschedule if needed. Priority propagation is broken and is thus disabled by default. The p_nativepri variable is only updated if a process does not obtain a sleep mutex on the first try. Also, if a process obtains more than one sleep mutex in this manner, and had its priority bumped in between, then p_nativepri will be clobbered. BSD
November 3, 2000 BSD
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy