An interesting operating system design

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
thre3dee
Member
Member
Posts: 34
Joined: Mon Nov 03, 2008 7:42 pm

Re: An interesting operating system design

Post by thre3dee »

01000101 wrote:This reminds me a lot of the AS/400 OS. It's files, 'folders', and libraries are all objects and so are programs and objects that compile them.

If you go the route of objects, please look at that OS and do 'almost' everything aesthetically different! It takes the complexity of a command line, and increases it 10-fold due to the odd sentence-like commands and object-based everything.
Well actually that was almost my exact idea. Even down to the kernel code. Since we have a C++ kernel project booting in Bochs there's no reason that we have to adhere to all the posix and 'standard' C/C++ conventions.

For example, instead of code like this:

Code: Select all

char tmp[256];
sprintf(tmp, "%d", myNum);
puts(tmp);
gets(tmp);
if (!strcmp(tmp, "EXIT"))
  _kexit();
Why can't our kernel code functions be like this? Using a little template object encapsulation in the process (like .NET formatting using argument indexes for better flexibity and safety such as the use of Arg<T>(arg)).

Code: Select all

char tmp[256];
FormatToBuffer(tmp, "{0:%d}{0:%02d}", Arg(myNum));
PrintString(tmp);
GetString(tmp);
if (!Compare(tmp, "Exit"))
    KernelExit();
As much as this is merely cosmetic change to standard C conventions, surely kernel code readability could benefit from not using obscure shorthand names like memcpy and strftime and vcnprintf etc. Even things like port I/O and other such low-level functions:

Code: Select all

PortOut(...);
PortIn(...);

// or this
OS::Port *OpenPort(...);
p->In();
p->Out();

// some threading code
OS::Thread *CreateThread(...);
OS::Thread *CallingThread(...);
thread->Terminate();
thread->Sleep();
if (thread->DidAwaken())
    scheduler->Schedule(thread);

// some console code
OS::Console *CreateConsole(...);
console->PrintFormat(...);
console->Clear();
OS::Stream *stdout = console->GetOutStream();
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re: An interesting operating system design

Post by Colonel Kernel »

JAAman wrote:actually, windows already does this (and has since at least win95, iirc) unfortunately most driver writers have refused to comply with this, and instead use the old ring0 driver system
Do you have a source for this? AFAIK, for all Windows versions prior to Vista, drivers must run in ring 0, with a few exceptions like printer drivers. The only use of ring 1 I'm aware of in Windows is when virtualization software runs a guest OS' "kernel mode" via ring compression instead of using the new VT extensions.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: An interesting operating system design

Post by JAAman »

never said it uses ring1 -- windows avoids use of ring1 at all, due to the OS-independent structure (windows was designed so that its applications (and maybe drivers) could run seamlessly on any OS, not just windows) and also for hardware portability

it actually uses ring3, and i know winXP drivers were ring3, i thought it was before that also, but i could be wrong...

there were however some exceptions -- certain 'core' drivers required for the basic operation of the kernel were required to be ring0 (not sure what all was in that though)

and all x86-64 windows versions require all drivers to be ring3... ring0 drivers have never been allowed in 64bit versions, since the drivers would need to be rewritten anyway, there was no reason to support ring0 there

the greatest advantage of vista is not visible to the user -- its the complete rewrite of the security layer and driver interface that make it so much more stable and secure than any previous version of windows, and its just too bad it has gotten such bad (and completely undeserved) press
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: An interesting operating system design

Post by AJ »

Hi,
JAAman wrote:it actually uses ring3, and i know winXP drivers were ring3
The public user mode driver framework was introduced with Vista, but was made available for XP (I have it installed as a separate update on XP if I go to add/remove programs). See here . MS had previously used ring 3 drivers with WMP10, but didn't make the interface public.
JAAman wrote:and all x86-64 windows versions require all drivers to be ring3
MS Website wrote:Kernel-mode drivers run in the same address space as 64-bit Windows.
Original quote here
Wikipedia also mentions on the XP versions page that "Only 64 bit kernel-mode drivers are supported" for XP64, which would indicate that they are ring 0.

As well as allowing ring 3 drivers (IIRC you can have ring0 elements for e.g. a video driver), I think one of the biggest changes in the vista driver interface is that all 64 bit drivers must be signed. On Vista 32 bit, you are warned about unsigned drivers but can continue anyway.

Cheers,
Adam
Post Reply