IPC Ideas

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!
Post Reply
indiocolifa
Member
Member
Posts: 41
Joined: Sat May 24, 2008 12:41 pm
Location: La Plata, Argentina

IPC Ideas

Post by indiocolifa »

I'm designing my first research OS and I want it to be extremely modular, so I expect the kernel to provide only the most basic services (VMM, IPC).

My current idea (i've no experience on microkernel or IPC -based design) is that the kernel contains a routing table for the system calls the applications can execute.

Suppose a basic system with kernel and services (I call services, Subsystems):

Code: Select all

SERVICE_ID, SERVICE_DESCRIPTION
0x0000 = KERNEL
0x0001 = VFS
0x0002 = VID
An application may call for example, a syscall to set the console background color:

Code: Select all

SETCONSOLEATTRIBS ( <params >);
This will issue a software interrupt to awake the kernel that a system call was executed by an application. In <syscalls.h> suppose we've a general definition for SETCONSOLEATTRIBS like:

Code: Select all

#define SETCONSOLEATTRIBS        0x295f         ; syscall number
So we send to the kernel a message with syscall and parameters:

Code: Select all

ProcessID, 0x295F, PARAM1, PARAM2
The kernel looks up the syscall routing table and founds 0x295F is a call to VIDSS, so sends to the video subsystem (by means of software interrupt?) the PID, the syscall and the parameters. So when VIDSS finishes it's task, can respond a status to the calling process through it's PID (so kernel it's not involved here).

Well, this is a very early approximation.

At least say that I'm crazy!

Note that at first i'm aiming at uniprocessor implementation (no multithreading here ).
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Post by JackScott »

I'm no expert at IPC, but one issue you are going to have to worry about is not hard coding values. With your current setup, the kernel has to know about every single call that can be made between two processes. A vast improvement would be a way for processes to register with the kernel what they support, and a way for other processes to query this. That would allow for a much more modular setup.

One problem that does arise out of this, though, is that you now can't simply send a message as send(VID,SETCONSOLEATTRIBS)... you'll have to work out a way for the kernel to know what process VID is, and that the procedure it supports is the one that is wanted. I hope I've explained this clearly enough.

These are just initial thoughts, I'm sure other forum members will come up with much more coherent criticisms.
User avatar
kmcguire
Member
Member
Posts: 120
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post by kmcguire »

The way I did it was:

Enumerating Services/Applications/Modules
You need some way to turn more common identifiers into numerical values. Some services that are critical to the system could be hard coded; just for example but not actually suggesting.. the VFS(Virtual File System).

So generally you could assign textual names to modules and let them register this with the kernel and associate it with their VID; or as their VID.

Enumerating Supporting Interfaces
You need to query a module once you have resolved the textual name into the VID about what interfaces it has to ensure that you are going to be able to communicate with it using a protocol the client supports.

A way to do this is to generate a globally unique identifier number for each interface created, just like COM on windows. Then you could sub that out with versions. Where the server (service, application, module) can provide one or many versions of a certain specific interface.

--

This should allow you to find X and query X for a protocol (interface) Z and essentially establish dependable and valid communication between client and X over Z.

Message Passing
If it is short messages you could pack them into registers and issue the software interrupt into the kernel and allow it to hand it over to the remote end; either by placing it in a buffer or alerting the remote end that it needs to issue a system call to get the short message.

If the message is long you could use pages or copy buffers from process space to process space. You could even use shared pages and create a ring buffer with locks and check so that reliable concurrent access by two processes simultaneously is possible.

Message Passing Methods

1. short message (passed via registers and read via registers)
This is fast, but you are limited to message size.
2. short message (passed via registers and placed in buffer on remote side)
This is faster, but still limited to message size.
  1. A structure supporting concurrent access could be used to allow server to check for messages. (faster)
  2. A system call could be used to check for messages. (slower)
3. long message (passed via copy memory from address space to address space)
This is slower, but supports large messages. But, the time to copy a message increases with every byte added to a message.
  1. A structure supporting concurrent access could be used to allow server to check for messages. (faster)
  2. A system call could be used to check for messages. (slower)
4. long message (passed by un-mapping page from client and mapping to server)
This is faster, but will cause the process to re-read the page table. So not sure which might be slower? Interrupt or flushing a table?
  1. A structure supporting concurrent access could be used to allow server to check for messages. (faster)
  2. A system call could be used to check for messages. (slower)
You will need a way for the remote end (server) to cleanup used pages after it has read the needed information from them. You will also need to think about a way to prevent DOS(Denial Of Service) attacks by flooding a process with messages.
5. long message (passed by mapping page from client to server)
This is about the same speed as 4.
  1. A structure supporting concurrent access could be used to allow server to check for messages. (faster)
  2. A system call could be used to check for messages. (slower)
You will need a way for the remote end (server) and local (client) to cleanup used pages after it has read the needed information from them. You will also need to think about a way to prevent DOS(Denial Of Service) attacks by flooding a process with messages.
6. long message/short message (passed using shared memory and reliable ring buffer)
This is very fast, but more complicated to implement.
  1. The kernel only maps pages allowing them to be shared. The protocol is completed implemented by the client and server. The kernel knows nothing about IPC between them.
You do not have to worry about cleaning up pages, or preventing a DOS attack -- and it should be really fast.
indiocolifa
Member
Member
Posts: 41
Joined: Sat May 24, 2008 12:41 pm
Location: La Plata, Argentina

Post by indiocolifa »

Wow, that was a reply! Thank you very much!
User avatar
devel
Member
Member
Posts: 62
Joined: Wed Nov 28, 2007 4:15 am
Contact:

Re: IPC Ideas

Post by devel »

Hi,
take a look at l4 kernel. You may find following slides Microkernel Construction (Lecture) quite useful.

Regards,
devel.
indiocolifa
Member
Member
Posts: 41
Joined: Sat May 24, 2008 12:41 pm
Location: La Plata, Argentina

Re: IPC Ideas

Post by indiocolifa »

Wow, very good thanks... =D>
Post Reply