Page 1 of 1
Timer
Posted: Mon Jun 14, 2004 11:00 pm
by prabuinet
Please help me,
How the programmable devices like RTC, PIT are used by an Operating System?
I like to know how should I (re)programme my RTC, PIT...
I think the timer interrupt is raised 18 times a second.
Should I change this frequency for my OS?
Does other OS's like Linux changes this frequency.
(thank's in advance)
-Prabu
RE:Timer
Posted: Wed Jun 16, 2004 11:00 pm
by Knicos
The PIT is used for multitasking, to cause a task switch.
Yes, the frequency can and is changed (i change it in my OS, to once every 10 milliseconds).
Here is the code I use to set the timer
Set_Interrupt(&do_timer, 0x20, INT_HARD_INT); //Install timer interrupt as schedule.
outb(0x43,0x36); //Enable timer
outb(0x40,timeinter); //Default timer speed low
outb(0x40,timeinter>>8); //Default timer speed high
outb(0x21,inb(0x21)&0xfe); //Enable interrupt.
RE: Quantum
Posted: Sat Jun 19, 2004 11:00 pm
by prabuinet
Should i check decrement the Quantum for every timer interrupt
and change the task when it becomes zero .
Or, should I set the timer according to the quantum so that it will raise an interrupt when the quantum is over.
Simply saying...
Whether most operating system's switches to another task at each timer interrupt
or it just decrements a counter (Quantum) and checks with an if (quantum > 0) to switch or not.
If it just decrements the counter.
then why don't we reprogram the pit according to the size of the quantum, so that we can avoid decrementing and checking...
I am sorry if u can't understand my english or what i'm trying to ask.
RE: Quantum
Posted: Sat Jun 19, 2004 11:00 pm
by Knicos
Most OS's do switch at each timer interrupt, so you should modify the PIT. Actually, most OS's do a bit of both, some tasks have higher priority so they may get 2 interrupts before they are switched out.
RE: Quantum
Posted: Mon Jun 21, 2004 11:00 pm
by GT
"If it just decrements the counter. then why don't we reprogram the pit according to the size of the quantum, so that we can avoid decrementing and checking..."
In my OS, I keep track of time to the nearest millsecond, but I don't really want to task switch every millisecond, so it makes more sense to tick and decrement than to reprogram the timer (which I need for my clock).