An OS without context switching

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.
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: An OS without context switching

Post by Casm »

nulik wrote:One approach would be to force the programmer to write small code snippets that would run for a short period of time and distribute the snippets evenly accross multiple cores. Lets say the programmers accepted this approach and started to write small code functions. But some code might present bugs, and could enter into infinite loop.
You might be able to do that in a hobby operating system, but I wouldn't try it commercially. Companies which try to tell their customers what they want, or even what they can have, tend not to last very long, because their putative customers keep their money in their pockets.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

Casm wrote:
nulik wrote:One approach would be to force the programmer to write small code snippets that would run for a short period of time and distribute the snippets evenly accross multiple cores. Lets say the programmers accepted this approach and started to write small code functions. But some code might present bugs, and could enter into infinite loop.
You might be able to do that in a hobby operating system, but I wouldn't try it commercially. Companies which try to tell their customers what they want, or even what they can have, tend not to last very long, because their putative customers keep their money in their pockets.
No I am not going to do this. I have already read lots of papers on OSes and this approach is bad. With this approach I will have to pass messages between processes and that will end up a slow OS like happened to Mach, which is micro kernel based. Monolithic kernel will win because with a syscall and no context switch it is going to do the job faster while the snippets will be flushing the TLB.
But I have a new idea to make an OS with:
  • No syscall overhead
  • No context switching
  • No TLB misses
I am just checking the manuals if the hardware will support my protection scheme.
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: An OS without context switching

Post by cxzuk »

nulik wrote:
Casm wrote:
nulik wrote:One approach would be to force the programmer to write small code snippets that would run for a short period of time and distribute the snippets evenly accross multiple cores. Lets say the programmers accepted this approach and started to write small code functions. But some code might present bugs, and could enter into infinite loop.
You might be able to do that in a hobby operating system, but I wouldn't try it commercially. Companies which try to tell their customers what they want, or even what they can have, tend not to last very long, because their putative customers keep their money in their pockets.
No I am not going to do this. I have already read lots of papers on OSes and this approach is bad. With this approach I will have to pass messages between processes and that will end up a slow OS like happened to Mach, which is micro kernel based. Monolithic kernel will win because with a syscall and no context switch it is going to do the job faster while the snippets will be flushing the TLB.
But I have a new idea to make an OS with:
  • No syscall overhead
  • No context switching
  • No TLB misses
I am just checking the manuals if the hardware will support my protection scheme.
I dont understand your goal?

If you have no context switch, it means you can only ever have one thread running.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

cxzuk wrote:
I dont understand your goal?

If you have no context switch, it means you can only ever have one thread running.
On the core it is running currently yes, but no thread runs forever. When a thread depends on other processes it can stop execution, new thread can be run on this core. Today's systems have 4 cores, you can run 4 threads in parallel, share the data using shared memory. A better workload organization can easily put an end to context switching, specially on Bulldozer cpus with 8 cores, you will have to redesign all the software though.
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: An OS without context switching

Post by cxzuk »

nulik wrote:
cxzuk wrote:
I dont understand your goal?

If you have no context switch, it means you can only ever have one thread running.
On the core it is running currently yes, but no thread runs forever. When a thread depends on other processes it can stop execution, new thread can be run on this core. Today's systems have 4 cores, you can run 4 threads in parallel, share the data using shared memory. A better workload organization can easily put an end to context switching, specially on Bulldozer cpus with 8 cores, you will have to redesign all the software though.
But once the thread ends, it has to do a context switch.

"When a thread depends on other processes it can stop execution, new thread can be run on this core." - Your talking about co-operative multitasking.

So from that, I think what you mean is no pre-emptive context switches.

If so, check out BareMetal (http://www.returninfinity.com/baremetal.html) as its aims are the same, code is very clean and done well.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: An OS without context switching

Post by gerryg400 »

nulik wrote:
cxzuk wrote:
I dont understand your goal?

If you have no context switch, it means you can only ever have one thread running.
On the core it is running currently yes, but no thread runs forever. When a thread depends on other processes it can stop execution, new thread can be run on this core. Today's systems have 4 cores, you can run 4 threads in parallel, share the data using shared memory. A better workload organization can easily put an end to context switching, specially on Bulldozer cpus with 8 cores, you will have to redesign all the software though.
I see no issue with that but this can be achieved with a Posix confirming microkernel like QNX Neutrino. You only need processor affinity, hard realtime scheduling and the ability to disable pre-emption on a thread-by-thread basis (using SCHED_FIFO) and you have it. Neutrino does all these things and additionally has things that really matter like adaptive, sporadic and partitioned scheduling.

[Edit] Just to be sure that I'm not seen as a QNX fanboy, I acknowledge that QNX is not perfect. I'm saying that Posix might already provide what you're looking for.
If a trainstation is where trains stop, what is a workstation ?
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

gerryg400 wrote: this can be achieved with a Posix confirming microkernel like QNX Neutrino.
Neutrino is almost perfect, the only problem is the proprietary license.
Besides BareMetal OS I have not found any cooperative multitasking OSes, so I probably will start my own project.
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: An OS without context switching

Post by rdos »

IMO, just providing cooperative multitasking features is of little interest. What is interesting is to provide hard realtime functions in a preemptive-multitasking OS, which is quite different. I think this can be done by allocating a core to a realtime-task (or tasks) that use cooperative multitasking. The hard thing is to let the realtime tasks use and communicate with ordinary OS functions. Just disabling preemption will not guarantee that a realtime task gets to run when it needs to. It takes much more than that.
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: An OS without context switching

Post by bontanu »

nulik wrote:
gerryg400 wrote: this can be achieved with a Posix confirming microkernel like QNX Neutrino.
Neutrino is almost perfect, the only problem is the proprietary license.
Besides BareMetal OS I have not found any cooperative multitasking OSes, so I probably will start my own project.
I guess that you did not search too well ;)

SolarOS is cooperative (an it has been from the start) and it is also realtime and it has an advanced API and GUI ;)

Even it there are no public releases lately be assured that it is still developed by me ;)

http://www.oby.ro/
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

bontanu wrote: SolarOS is cooperative (an it has been from the start) and it is also realtime and it has an advanced API and GUI ;)

http://www.oby.ro/
awesome!
I downloaded sol_os_2009_07_22_v0_104_05.zip but where are the sources ? can't find them. also qemu complained about floppy and aborted the boot process.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: An OS without context switching

Post by Brynet-Inc »

I don't think he releases source anymore, but you never know, he's gone back and forth often enough.

I remember trolling on his forum a few years ago. Fun times.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

Brynet-Inc wrote:I don't think he releases source anymore, but you never know, he's gone back and forth often enough.

I remember trolling on his forum a few years ago. Fun times.
don't worry, if finish my (cooperative) OS it will be GPL
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: An OS without context switching

Post by Brynet-Inc »

nulik wrote:don't worry, if finish my (cooperative) OS it will be GPL
I'm worried.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
sandras
Member
Member
Posts: 146
Joined: Thu Nov 03, 2011 9:30 am

Re: An OS without context switching

Post by sandras »

nulik wrote:don't worry, if finish my (cooperative) OS it will be GPL
I'm worried.

Not to start a license flame war, I would choose something that is short and to the point - I still haven't read all of any of the GNU licenses and I probably never will, because they are so long, complex and mind numbingly boring, I only sort of know what they say from other sources. Whether I agree with them is another story.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

Found another OS that is supposedly without context switching:
http://tech.slashdot.org/story/09/02/06 ... century-os
Code: http://code.google.com/p/phantomuserland/
I personally don't like object oriented stuff (because it is slow) , so I doubt this OS will be faster than Linux, because if the kernel does range checking in code and there is a lot of messages between objects, this OS will be the slowest ever. The best way is to rely on page fault checking mechanism which is done in hardware.
Post Reply