Timer

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
prabuinet

Timer

Post 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
Knicos

RE:Timer

Post 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.
prabuinet

RE: Quantum

Post 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.
Knicos

RE: Quantum

Post 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.
GT

RE: Quantum

Post 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).
Post Reply