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.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

berkus wrote:Come on, dz didn't publish anything working yet. Phantom is just some experimental "vaporware".
I thought that too, but apparently there is a code and it is running, see screen shot:
http://phantomuserland.googlecode.com/f ... 10_SMP.png
And I think this is the kernel:
http://code.google.com/p/phantomuserlan ... p&can=2&q=
(i didn't test it)
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 »

Looking at the screenshot I see 6 threads in the _run_ state. 3 of those threads are marked as CPU 2. In fact there appear to be 9 threads in various states on CPU 2. That implies context switching. I call BS on the implementation. Or did I misunderstand ?
If a trainstation is where trains stop, what is a workstation ?
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: An OS without context switching

Post by cxzuk »

Phantom runs threads, so why wouldnt it have a context switch?
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 »

Because the FAQ says there are no context switches.
But the wiki page on KernelThreads says wrote:Phantom kernel is preemptively multithreaded. Threads sync API (see KernelSync) is more or less the same as in pthreads, but not exactly.
If a trainstation is where trains stop, what is a workstation ?
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: An OS without context switching

Post by cxzuk »

I can only assume it means the kernel doesn't cause a context switch.. but nulik refers to the OS not causing context switches?

KernelSync discusses disabling interrupts to stop context switchs o_O
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 can only assume it means the kernel doesn't cause a context switch.. but nulik refers to the OS not causing context switches?

KernelSync discusses disabling interrupts to stop context switchs o_O
would it be "semi-preemptive" then ? ehm, don't know, just kidding. kernel sources aren't published.

From what I understand from PhantomArchitecture page on the wiki is that the kernel has the virtual machine inside, so it is the virtual machine that interprets all the methods (bytecode) of the objects, i.e a single application running on one core, sort of applies as being no context switched from a unix point of view, but there are lots of threads inside virtual machine, and each thread of course is context switched....
This is what I understood, but I think on the first benchmarking (measured as amount of webserver requests per second from another machine, for example) it will show poor performance, because it is interpreted.
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 can only assume it means the kernel doesn't cause a context switch.. but nulik refers to the OS not causing context switches?

KernelSync discusses disabling interrupts to stop context switchs o_O
would it be "semi-preemptive" then ? ehm, don't know, just kidding. kernel sources aren't published.

From what I understand from PhantomArchitecture page on the wiki is that the kernel has the virtual machine inside, so it is the virtual machine that interprets all the methods (bytecode) of the objects, i.e a single application running on one core, sort of applies as being no context switched from a unix point of view, but there are lots of threads inside virtual machine, and each thread of course is context switched....
This is what I understood, but I think on the first benchmarking (measured as amount of webserver requests per second from another machine, for example) it will show poor performance, because it is interpreted.
I think its safe to say there is no way to get around a context switch. They are a critical part of the computer.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: An OS without context switching

Post by Combuster »

cxzuk wrote:I think its safe to say there is no way to get around a context switch. They are a critical part of the computer.
That's not true. The problem is that eliminating context switches (as opposed to bluffing your way out by giving it a different name) means a single program single tasking system. For a lot of embedded applications that's quite sufficient, but for an OS of any meaning it is simply an requirement - after all, even DOS has context switches. It's fast because there are always exactly two switches per task, which happens to be the academic minimum.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: An OS without context switching

Post by nulik »

Combuster wrote: The problem is that eliminating context switches means a single program single tasking system
as I understand, context switch is INTERRUPTION of a running process to give time to another process. But you can run many tasks of the same program until the program can't continue because of dependencies with other programs. The program will have to leave the CPU. This will be a MULTI tasking system on ONE core.
So, it IS possible to have an OS without context switching.
The problem is to organize the software to execute in a cooperative way, probably the programs must be behaving more like libraries than as independent applications. Unix was developed 50 years ago, and computers were single CPU, so you had to do context switching. Today we have multicore systems that can easily distribute tasks on different cores being free to run the time slice they need, but the preemptive paradigm keeps dragging developers into the old style.
I do not have a ready solution yet using cooperative multiasking, but this is the idea and I am working on it.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: An OS without context switching

Post by jnc100 »

From what I gather, Phantom does away with the idea of a process (i.e. a collection of threads within a single address space) and has all programs which are loaded create any number of threads within a single global address space (with memory protection provided by software). Switching between threads still exists (presumably in the standard timer interrupt-driven pre-emptive way) but these only require changing of the cpu registers, rather than the address space as well (cr3 in intel parlance), thus reducing tlb misses. This is similar to the way most current managed code os's work on 64 bit architectures.

Regards,
John.
Post Reply