manish
manish

Reputation: 311

Timers in operating Systems

"We can use the timer to prevent a user program from running too long. A simple technique is to initialize a counter with the amount of time that a program is allowed to run. A program with a 7-minute time limit, for example, would have its counter initialized to 420. Every second, the timer interrupts, and the counter is decremented by 1. As long as the counter is positive, control is returned to the user program. When the counter becomes negative, the operating system terminates the program for exceeding the assigned time limit."

From this paragraph i cannot understand how some of the user programs (like the applications on windows) can run continuously until closed by the user.Are there no time limits on those applications?

Upvotes: 1

Views: 8362

Answers (1)

Martin James
Martin James

Reputation: 24907

Typical edsktop OS do not impose time quotas.

The timing mechanism you describe is not appropriate for anything except trivial embedded applications. Modern multitasking OS have more structured and efficient timing mechanisms.

If many apps are running 1000 timers between them, it would be wasteful and pointless to continually count-down 1000 counters - it is only necessary to count down one value - the one with the nearest, (chronologically), timeout time.

It's fairly easy for a Windows app to set a 'lifetime' for itself internally, but there is, AFAIK, no specific process attribute for lifetime in the OS.

Upvotes: 3

Related Questions