OS with no timers.. at all ?

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.
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

Ok,

So this idea is not good. The goal is to let the hardware do as much as possible.

So apic timer has no real workaround (on x86_64)..

Thanks
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: OS with no timers.. at all ?

Post by Brendan »

Hi,
AlexHully wrote:So this idea is not good. The goal is to let the hardware do as much as possible.

So apic timer has no real workaround (on x86_64)..
Work around for what?

All hardware requires initialisation; which can be many things; like self-tests, determining resources (memory mapped areas, IRQs, etc), detecting capabilities, detecting/enumerating any "child devices" that are attached, etc.

The initialisation of local APIC mostly involves detecting its presence, detecting its capabilities, calibrating its timer, testing that its functioning correctly, and configure it for however you're planning to use it. None of these things are work-arounds, they're all just "business as usual".


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

I was talking about the fact that, yes, one needs timers, no way around that.

Thanks a lot for your patience, i will come back with some other silly questions :D
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: OS with no timers.. at all ?

Post by iansjack »

Kevin wrote:
iansjack wrote:
Kevin wrote:Also, if you really were to write an OS without any timers, how would you implement something as simple as a clock in the user interface?
Simple. Just use a RTC chip. Reading it can be purely a user-space process with no support needed for it in the OS.
I assume that you just mean reading the current time, because using the RTC IRQ would mean using a timer. If so, that's good enough for implementing something like a "date" command, but for a permanently displayed clock, how do you know when to update the displayed time?
No, I was thinking about a permanently displayed clock. It doesn't have to be updated at regular intervals. For example, you could just update it every time a keystroke was received or every time a newline was written to the screen. Not perfect, but I'm sure I remember OSs that displayed a clock in that manner.

Of course this is begging the question of whether an OS needs to display a clock. MS-DOS didn't and I think it would be difficult to argue that it wasn't an OS. I can't remember a real-time clock being displayed as part of OS/400, and that certainly qualifies as an OS.

In my list of essential services that an OS provides I wouldn't list "displaying a constantly updated clock".
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: OS with no timers.. at all ?

Post by Kevin »

My point wasn't that you can't have an OS without timers or that a permanently displayed and automatically updated clock is a requirement before you can call it an OS, but just to illustrate that it would be a severely limited OS. DOS itself didn't display a clock, but it was easy enough to write a program to do so (in fact, this was the example that my Turbo Pascal book used to demonstrate TSRs :)). In an OS without timers you couldn't write such a program unless you resort to busy waiting.

And it was only one (very obvious) example. Brendan mentioned a few more where timers are pretty much essential.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: OS with no timers.. at all ?

Post by Muazzam »

AlexHully wrote:A question mark counts as a word.
It doesn't. See: http://www.quora.com/Why-do-many-Indian ... tion-marks
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

==
Last edited by AlexHully on Wed Jul 22, 2015 1:49 pm, edited 1 time in total.
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

muazzam,

Quora is by no mean a reference here.
Why not just open a book (litterature, the real deal) and check by yourself ?

Please don't take my comment as being offending, it is not.
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: OS with no timers.. at all ?

Post by Octocontrabass »

AlexHully wrote:Why not just open a book (litterature, the real deal) and check by yourself ?
Why not ask someone whose native language is English? I'm not the only one here, right?

In English, there is no space before the question mark.
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

Ok,

It depends on the native language. In my language (French), there is a space (I lost so many points because of it at the university). And since I am writing in English, I should not put a space.

Lesson learned. :wink:

-- first post corrected.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: OS with no timers.. at all ?

Post by kzinti »

AlexHully wrote:Ok,
It depends on the native language. In my language (French), there is a space (I lost so many points because of it at the university). And since I am writing in English, I should not put a space.
But not in French Canadian! :P
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: OS with no timers.. at all ?

Post by AlexHully »

:D =D>

(my knowledge on the topic looks so contrived right now XD, but it still holds for french "L'honneur est sauf !")
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: OS with no timers.. at all ?

Post by Kevin »

Oh, so your native language is actually French? I wondered about exactly that because French is the only language of which I know that it adds these spaces, but I didn't want to ask and embarrass myself. :)
Developer of tyndur - community OS of Lowlevel (German)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: OS with no timers.. at all ?

Post by alexfru »

AlexHully wrote: The question will be short : could a OS exist without timers?
I mean, no need for cron, watchdogs, tickless kernel.

No timers at all.

Is it a stupid idea to implement?
You could implement some kind of cooperative multitasking so as not to require an external event to drive task switching in the scheduler, but you then run into the problem of needing to make sure that no task hangs or crashes because that would stop the entire system. And every potentially long loop would need to be broken out of every now and then in order to let something else run for a while. Manually rewriting loops in order to be able to enter and exit them at will while maintaining program state is not a fun thing to do. Also, the CPU wouldn't appreciate many frequent jumps between different parts of different programs. You'd need to do some tuning. In some special (and extremely simple?) cases this may be reasonable. But it's not a good choice for a more or less general system. Early versions of Microsoft Windows and Apple Mac OS suffered from the drawbacks of cooperative multitasking, while they obviously did service timer interrupts.
AlexHully wrote: It sounds very appealing, not talking about the complexity of such an OS : much simpler. Scheduler : much simpler (tickless).

Overall : simpler/faster.
Not everything is simpler or faster. It depends.

There exist systems (hard realtime?) with static/fixed scheduling driven by events/interrupts occurring periodically at a constant rate. Every task must start and complete between two such subsequent events/interrupts. With such a design you can, on one hand, avoid certain types of problems associated with preemption and race conditions, on the other hand you waste time or you need to bind several tasks together to make use of the most of the CPU time between the events and given the complexity and "variability"(?) of software (different paths through it taking different amounts of time (also remember of the previous state/cache effects)) you're risking to miss deadlines. You may switch the CPU to a low power state between completion of one task and starting of another. That will conserve energy, but the latency will stay. Again, there are certain benefits to this design, but it doesn't look like a good choice for a general-purpose system.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: OS with no timers.. at all ?

Post by Kevin »

alexfru wrote:Also, the CPU wouldn't appreciate many frequent jumps between different parts of different programs.
If anything, you have more switches with a timer interrupt enabled.
Developer of tyndur - community OS of Lowlevel (German)
Post Reply