LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-21-2011, 04:28 PM   #1
navarromoral
LQ Newbie
 
Registered: Feb 2010
Posts: 3

Rep: Reputation: 0
Scheduler and timer


Hello everybody! I would like to ask the following

- First I'll assume (please correct me) the schuduler is called periodically via an IRQ (I suppose this IRQ is the IRQ0, which is assigned to the timer).

So let's suppose thread A is running, then the scheduler is called and decides to change to thread B because the quota of thread A has expepired.

My question is: how is it possible not to return to thread A when the ISR of the timer is done (if the interrupt was raised while thread A was executing, then when the ISR is finished it should return to thread A)

And also, if interrupts are disabled, how can the scheduler be called if there are no longer timimg interrupts.

Thanks a lot in advanced!!
 
Old 06-22-2011, 08:34 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,609
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
When a thread or process is given control of a CPU, it will maintain control until it is interrupted for some reason. An I/O operation, a program exception, the time-of-day clock, or the timer ("heartbeat") interrupt, all could generate such interrupts.

Incoming interrupts are managed by a PIC, or Programmable Interrupt Controller, which is a piece of hardware that's controlled by the operating system. It prioritizes the incoming interrupts, and it can defer them. It can sense when the CPU is running with interrupts more-or-less disabled. (I say, "more or less," because the CPU can selectively disable some interrupts while enabling others.) It's possible for an interrupt to be delayed without being lost. (It's also possible that the interrupt will be lost.)

When an interrupt occurs, it is first serviced by a first-level interrupt handler, which collects status and squashes the source of the interrupt ("turns off the alarm clock so the damn thing doesn't keep ringing ..."). It then schedules, by some means, the second-level interrupt handler to be executed at some convenient time in the near future. (Think of it like a "snooze button" on that clock.) The actual implementations of this have evolved over time, but those gory details, while interesting, are not important here.

Usually, the next thing that happens is a trip to schedule.c, which is the master dispatching routine that decides "what happens next." If the scheduler decides to switch to some other unit of work, it saves the status of the unit of work that had been running previously, so that it can be restored later, thereby resuming that unit. Meanwhile, it loads the status of the unit of work that it has selected, thereby resuming that unit.

(There are many kinds of "units of work" to choose from, including threads and second-level interrupt handlers.)

Last edited by sundialsvcs; 06-22-2011 at 08:38 AM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scheduler available on Linux? NY-Ed Linux - Newbie 1 10-12-2010 10:13 AM
kernel scheduler robzane Linux - General 6 05-21-2009 12:51 AM
How can I get LAPIC timer to run instead of the PIT timer? sixerjman Linux - Kernel 1 10-16-2007 09:59 PM
Multimedia timer (SMP friendly timer) bigqueso Linux - Kernel 0 03-15-2007 03:49 PM
scheduler... os2 Programming 0 07-24-2004 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:31 AM.

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