Page 2 of 3
Re: OS with no timers.. at all ?
Posted: Tue Jul 21, 2015 11:29 am
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
Re: OS with no timers.. at all ?
Posted: Tue Jul 21, 2015 12:50 pm
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
Re: OS with no timers.. at all ?
Posted: Tue Jul 21, 2015 3:08 pm
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
Re: OS with no timers.. at all ?
Posted: Tue Jul 21, 2015 4:06 pm
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".
Re: OS with no timers.. at all ?
Posted: Tue Jul 21, 2015 4:26 pm
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.
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 8:28 am
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
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 1:45 pm
by AlexHully
==
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 1:49 pm
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.
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 2:21 pm
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.
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 2:32 pm
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.
-- first post corrected.
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 2:54 pm
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!
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 2:56 pm
by AlexHully
(my knowledge on the topic looks so contrived right now XD, but it still holds for french "L'honneur est sauf !")
Re: OS with no timers.. at all ?
Posted: Wed Jul 22, 2015 4:46 pm
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.
Re: OS with no timers.. at all ?
Posted: Thu Jul 23, 2015 12:41 am
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.
Re: OS with no timers.. at all ?
Posted: Thu Jul 23, 2015 1:21 am
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.