Internal Structure Questions (Minix)

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.
Post Reply
calpis

Internal Structure Questions (Minix)

Post by calpis »

I am reading a book on Minix, overview of processes in minix then got confuse.

Minix structured in 4 layers

Layer 4 User Processes (init,user proces etc)
Layer 3 Server processes ( Memory manager, File system, Network server
Layer 2 I/O tasks (disk task, Tty task, clock task, system task etc)
Layer 1 Process management

My question is:

What is I/O tasks(it is also called driver device)?

Why isn't Process management in Layer3 as a server?

I am getting more and more confuse...

Thanks in advances
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Internal Structure Questions (Minix)

Post by Pype.Clicker »

well, that 'layered' structure is something very specific to minix. I suppose it will get clearer while getting further in the book, but since i know a little about minix, i won't try guessing more.
calpis

Re:Internal Structure Questions (Minix)

Post by calpis »

So if I say I want to design a Micro-kernel, can I use the following layouts?

Layer 3 Users processes
Layer 2 Servers processes ( Process Mgt, FS, Device Mgt, and so on)
(user space)
-------------------------------
(kernel space)
Layer 1 Microkernel ( Message passing...

I am trying learn to design a fast microkernel Like QNX.
Curufir

Re:Internal Structure Questions (Minix)

Post by Curufir »

chaisu chase wrote: Why isn't Process management in Layer3 as a server?
It could just be reflecting x86 architecture. Process management has to load CR3 at some point (if you use paging) and that's a ring0 only operation.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Internal Structure Questions (Minix)

Post by Colonel Kernel »

@Curufir: Minix uses segmentation without paging.

@chaisu:
Don't pay too much attention to the layers in Minix. I think this is actually a serious design flaw that introduces a lot of unnecessary overhead into the system. For example, it doesn't make much sense from a performance standpoint to have the disk driver and FS be in separate tasks. But then again, Minix doesn't support multithreading, so it would be hard to combine them efficiently. :P

QNX doesn't even have "layers" really -- just servers in user space and the microkernel. Even the Process Manager is a user space server, even though its code is part of the kernel image.

I guess I'll sum up my opinion by saying that Minix is pretty crappy. :) It's useful for learning about implementation details, but its design is a combination of the worst attributes of microkernels and monolithic kernels IMO.
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!
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Internal Structure Questions (Minix)

Post by distantvoices »

The most disturbing thing I've found in Minix is this "common driver interface" - a collection of pointers to functions inside the driver as well as common functions like receive & send - which each task has to instantiate - it makes things a wee bit complicated to read, especially in minix, with all this cross copying between segments.

But eventually one gets his way around and finds out how things work in the minix world.

Other than that - I don't think minix is crap. It has taught me quite a bunch despite several bottle necks and design flaws (which I have avoided - threaded file system service in BlueIllusion f. ex.)

just my 2 cent. (formerly known as Groschen)

stay safe.

BTW, as this is my 1000'th post, here's the promised

****rack o'beer**** (gulp)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
calpis

Re:Internal Structure Questions (Minix)

Post by calpis »

"Even the Process Manager is a user space server, even though its code is part of the kernel image."

Does the kernel contain an IPC dealing with message and task or thread scheduling?

So what does the Process Manager do in user space?

And does other components such as file system, memory manager, communicate with only the kernel to instruct the process manager?

Or each components can communicate with each other with or without the kernel? Like a bus rather than a star topology.

Do they have more than one IPC in user space and kernel space?

Thanks in advance. I am so confuse...
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Internal Structure Questions (Minix)

Post by Colonel Kernel »

chaisu chase wrote: "Even the Process Manager is a user space server, even though its code is part of the kernel image."

Does the kernel contain an IPC dealing with message and task or thread scheduling?
Yes, in QNX the kernel has all of the above.
So what does the Process Manager do in user space?
It manages address spaces I think... whatever parts of virtual memory management that don't actually have to run in kernel-mode (i.e. -- the kernel itself almost certainly has to load CR3 on process switches, and probably manage some minimal set of page tables). It's hard to find details about this on the QNX website or in books, so to a certain extent I'm just guessing.

The Process Manager also allows processes to find each other when they want to do IPC. It is the "resource manager" in charge of the / directory. Without the Process Manager, the concept of the directory tree wouldn't really exist.
And does other components such as file system, memory manager, communicate with only the kernel to instruct the process manager?
In QNX, the process manager is the memory manager. File systems are actually shared libraries loaded by the disk drivers (IIRC), which themselves are just user-space servers. They all use IPC to communicate with each other via the kernel (i.e. -- the kernel itself implements IPC).
Or each components can communicate with each other with or without the kernel? Like a bus rather than a star topology.
The kernel is involved in all IPC, but it is really just the go-between for most things. There are no rules like "server A must send messages to server B, then server B will forward them to the kernel"... This kind of weirdness from Minix makes my head hurt. :P

The only time an intermediary is required is when two processes need to find each other. For example, if process A calls fopen( "/home/joe/foobar" ), this results in a message being sent to the Process Manager to resolve the path into a target for future IPCs. In this case, /home probably maps to /dev/hda1/home or something like that (sorry if I got *nix drive names wrong), so the Process Manager would return the channel ID (if we're talking QNX Neutrino) of the appropriate server back to process A. From that point on, process A can send messages to the server directly.

Yes, I think it would be accurate to describe QNX as following a bus topology, where the microkernel is the bus.
Do they have more than one IPC in user space and kernel space?
IIRC, the Process Manager in QNX emulates the more "heavy-weight" IPC mechanism like pipes by using the more "light-weight" message passing implemented in the kernel itself. Most of the time IPC in QNX is done with the kernel message-passing system calls... things like pipes exist only for POSIX compatibility.
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!
calpis

Re:Internal Structure Questions (Minix)

Post by calpis »

Thank you for your explainations and opinions. I think I am more clear now...

Could I just ask this. With microkernel, which is the fastest? And why? Its there any way to improve it?

I just want to learn.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Internal Structure Questions (Minix)

Post by Colonel Kernel »

Which is the fastest what? I think you need to rephrase the question. Is it: "Which is the fastest Microkernel?" or "Which is faster, microkernels or other types of kernel...?"
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!
calpis

Re:Internal Structure Questions (Minix)

Post by calpis »

I meant Which is the fastest microkernel? And why is that? Can we do better to improve microkernel.

Sorry if I confuse anybody.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Internal Structure Questions (Minix)

Post by Colonel Kernel »

Normally, I would want to qualify the question by asking, "fastest microkernel for what?" But since microkernels by definition aren't supposed to do many different things, maybe the question can be answered in general. :)

Since a microkernel is really there to act as a message "bus" between processes, I would argue that a microkernel's performance can best be measured in terms of its context switching time, and in terms of how well it scales to multiple processors (i.e. -- the inverse of how bad the lock contention is).

I don't know of any scalability benchmarks, but I've read that QNX and L4 have about the fastest context switching times around. I think they achieve good performance because they stick to the principle that less is more. The fewer services a microkernel has to provide, the less complex the code has to be. This should mean fewer locks and faster code-paths for system calls and context switches. I say "should" because I'm still writing my first OS, so I'm learning whether this is true for real. :) Most of what I know about OS design I learned in university, where things can tend to get a little too theoretical.
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!
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Internal Structure Questions (Minix)

Post by distantvoices »

Hm.

How efficient the micro kernel can serve your average tasks is sometimes dependent on how you schedule the tasks - i. e. how your task queues are organized.

In my own OS, there's a possibility to have about 255 levels of priority compiled in. For the sake of sanity, I have only 10 of them in use actually, because more one doesn't need - and after all, I'm gonna change my scheduling stuff to something different soon in order to get rid of some of the most annoying lags: a driver running prevents a server to run. a server prevents a user task to run - say, there is the possibility for a task to starve. (not as if my services are greedy - they sooner or later give up cpu - as soon as there are no more messages to process...)

Further, think about the messaging: are you about to do async messaging or sync. rendezvous message passing? Both have advantages and disadvantages I daresay.

As for making your first micro kernel the most effective one: I've heard a saying in these Forums:

Premature Optimization is the Root of all Evil.

Say: get it running first. Then get it running smoothly and safe. And after that you might think about optimizing stuff and about : "Man, that canna be. Couldn't we do that in a BETTER way?" (Mensch des gibts ned, des kunnt ma doch irgendwie besser mochn!)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Post Reply