SourceForge.net Logo

ManRiX
THE DESIGN OF ROBUST AND EFFICIENT MICROKERNEL

Support This Project Donation
  Development :
 
     Mailing List Archive
  Downloads
  Sources
  FAQS
  Resources
  Developers
  Browse CVS

Ext2Read project:
This is the project we have done which read ext2 partition from the DOS.
To Download click

Home | Back  
 
Google Search
SourceDownload
Intel Manuals
OS Resources
Forums
Contact
Status of Project
Papers

Contributers
of the project and sponsors

ManRiX Microkernel Services :
Thread And Process managenemt
Symmetric Multiprocessor(SMP):
Interprocess Communication:
Virtual Memory management:

Timers management:
Signal management:
Exception & IRQS:
Kernel Preemption:
Schedular

ManRiX's Microkernel Architecture

                                 

ManRiX is a microkernel based operating system. Microkernel contents the few essential servicea of kernel. Those components which are not required inside kernel are implemented as user servers . The ManRix microkernel performs the following tasks:

•  Thread Management.
•  Inter Process Communication (IPC) using Message Passing.
•  Memory management.
•  Signal & Timer management.
•  Exception and IRQ handling:

OS Initialization:
The OS initialization Process is Architecture Dependent. We will try to explain how ManRiX is initialized in I386. After the Microkernel Image and System Servers’ Image are loaded in memory by Boot Loader, the _start function on kernel_entry.S begins to execute and later calls the C function ManRiX_main(). The kernel only runs on the Context of a process during System Calls and on the Interrupt Context during Interrupt. Overall step how ManRiX boot can be found in this link.

Thread and Process Management:
   

Processes and Threads are the two basic concepts of program. In ManRiX microkernel, threads are the fundamental units of execution. Processes are inactive entity. Process just encapsulates the threads and address space. Threads are scheduled independently no matter to which process they belong. Each thread has two set of Stack one for running in Kernel Mode called Kernel Stack and for User stack for user mode.
Each process contains a unique Process ID called pid and each thread contains unique thread ID called tid. The pid and tid are not unique to each other. The Users can Create Process by using POSIX fork and exec functions and Threads by using pthreads functions.

Interprocess Communication:              

Inter Process Communication is Heart of any Microkernel Based System. In ManRiX Microkernel, Message passing is used as the IPC. We are using Synchronous message passing. The message is sent directly sent to another thread using tid. There are basically three types of Messages in ManRiX. We have basically three types of Messages. They are SHORT, LONG and MAP.

The SHORT messages are passed Only in CPU Registers. This is used in IPC where messages to send and receive are very short and fit in general purpose resisters. This type of message passing is extremely fast but can accommodate short messages (32 bytes).
In LONG messages, the Messages are copied from one Address Space to another. This is not possible directly so we are first copying to Kernel and then to another address space. Usually, the Messages shorter than 256 Bytes are Long Transferred. It is quite slower than SHORT messages.
And In the MAP messaging, the messages are NOT actually transferred but the page tables are mapped. This is not efficient For short messages.

Signal Management:                     


Signals provide a mechanism for notifying processes of system events. They also function as a primitive mechanism for communication and synchronization between user processes. ManRiX supports POSIX signals. It has also a limited support of POSIX real-time signals. ManRiX supports 32 different signals. 26 of them are standard POSIX signals and 5 are Real-time Signals. In ManRiX signal handlers are per process objects. All threads in a process share same signals handlers but have their own signal mask.

The supported non-real signals are (from SUSV3)

Signal

Default Action

Description

SIGABRT

A

Process abort signal.

SIGALRM

T

Alarm clock.

SIGBUS

A

Access to an undefined portion of a memory object.

SIGCHLD

I

Child process terminated, stopped,

 

 

or continued.

SIGCONT

C

Continue executing, if stopped.

SIGFPE

A

Erroneous arithmetic operation.

SIGHUP

T

Hangup.

SIGILL

A

Illegal instruction.

SIGINT

T

Terminal interrupt signal.

SIGKILL

T

Kill (cannot be caught or ignored).

SIGPIPE

T

Write on a pipe with no one to read it.

SIGQUIT

A

Terminal quit signal.

SIGSEGV

A

Invalid memory reference.

SIGSTOP

S

Stop executing (cannot be caught or ignored).

SIGTERM

T

Termination signal.

SIGTSTP

S

Terminal stop signal.

SIGTTIN

S

Background process attempting read.

SIGTTOU

S

Background process attempting write.

SIGUSR1

T

User-defined signal 1.

SIGUSR2

T

User-defined signal 2.

SIGPOLL

T

Pollable event.

SIGPROF

T

Profiling timer expired.

SIGSYS

A

Bad system call.

SIGTRAP

A

Trace/breakpoint trap.

SIGURG

I

High bandwidth data is available at a socket.

SIGVTALRM

T

Virtual timer expired.

SIGXCPU

A

CPU time limit exceeded.

SIGXFSZ

A

File size limit exceeded.

Where, First row denotes Symbolic Name for signal. Second row shows the default action to take on signal receipt.

I = ignore
T = terminate
A = Abort
S = Stop process
C = Continue process
The real time signals are from SIGRTMIN to SIGRTMAX. The signal handlers are the per process entity whereas signal mask are per thread entity. If a thread catches a thread, it affects all the threads belonging to that process. If a signal is targeted to a process, the thread which has that signal unblocked will receive the signal. The signal is checked while returning from kernel. So, the signal may not be delivered as soon as it arrives.
In microkernel, all signals are queued. The ignored signals are not queued. Our OS has 5 system calls related to POSIX signals.

1.Signal_action:This system call defines action to take on receipt of a signal. The parameters are

•  signal number
•  Pointer to act structure
•  Pointer to oact structure

This system call is used to service following POSIX calls.
int sigaction(int sig , const struct sigaction *restrict act ,
       struct sigaction *restrict oact );
void (*signal(int sig , void (* func )(int)))(int); (ISO C standard)

  1. sig_mask
    This system call change blocked signal mask of a thread. The parameters are:
    •  How field
    •  Pointer to set structure
    •  Pointer to oset structure

This system call is used to service following POSIX calls.
int pthread_sigmask(int how , const sigset_t *restrict set ,
       sigset_t *restrict oset );
int sigprocmask(int how , const sigset_t *restrict set ,
       sigset_t *restrict oset );
kill

This system call sends a signal to a particular thread or process. The parameters are:
•  pid or tid
•  signal number
•  flags

SIG_REAL /* for sigqueue */
TO_THREAD /* signal sent to a thread eg. pthread_kill()*/
TO_PROCESS /* signal sent to a process eg. kill() */
•  pointer to sigval (used by sigqueue)

This system call is used to service following POSIX calls.
int kill(pid_t pid , int sig );
int raise(int sig );
int sigqueue(pid_t pid , int signo , const union sigval value );
int pthread_kill(pthread_t thread , int sig );

signal_suspend :

This system call suspends the thread until any signal is delivered. The parameters are:
signal set (used by sigsuspend)

This system call is used to service following POSIX calls.
int sigsuspend(const sigset_t * sigmask );
int pause(void);
1. sigreturn
This system call is used to return from user's signal handler.

Timer Management:                          

Timer notifies a thread when the time as measured by a particular clock has reached or passed a specified value, or when a specified amount of time has passed ManRiX support limited POSIX timers.

Schedular:                        

ManRiX supports POSIX style scheduler. There are three scheduling policies, SCHED_FIFO (First in-first out (FIFO) scheduling policy), SCHED_RR (Round robin scheduling policy) and SCHED_OTHER (Another scheduling policy). SCHED_FIFO and SCHED_RR are used for real time threads and SCHED_OTHER is used for time sharing threads. The system threads use SCHED_OTHER but have a higher priority than normal threads. There are 128 priorities where numerically lower value means low priority and vice versa. The SCHED_FIFO and SCHED_RR policies have priorities ranging from 88 to 119. They have static priorities. The SCHED_OTHER priorities range from 4 to 87. The range from 0 to 3 is for idle threads. The system threads (i.e. file servers, consoles etc) use the policy SCHED_OTHER and have priorities from 46 to 87. The priorities for system threads are static. There are also special threads which handle interrupts called interrupt threads. They have the highest priority ranging from 120 to 127. The normal threads have priorities.
The ManRiX scheduler is capable of distinguishing between interactive and non interactive threads. The interactive threads are I/O bound i.e. they spend most of their time waiting for an I/O event. In the other hand, the non interactive threads are CPU bound i.e. they spend most of their time using CPU. So, the priorities of interactive threads should be higher than that of non interactive threads. The scheduler increases the priority of interactive threads when they go to sleep and decreases the priority of the non interactive threads.

Since ManRiX supports SMP systems, the scheduler should be able to schedule threads in all existing processors. In ManRiX, each processor has its own run queue. Since the run queue is a per processor object, there is no need to lock the run queue. One of the special features of ManRiX is automatic balancing of CPU load. There is no need to migrate the thread from one processor to another. Each run queue contains a counter of total no of threads in running in that processor. There is a hint pointing to the run queue having least no of threads. Now, during enqueuing, a thread is enqueued to the run queue pointed by the hint. This hint is updated either by idle thread or the timer interrupt code on every 500ms on loaded systems.The below figure depics ManRiX's schedualr concepts.

 
Exception and IRQ Management:          
 
 

ManRiX does not handle devices in kernel space. They can be implemented in user space using a set of interfaces. The ManRiX microkernel sends appropriate signals to the corresponding threads on CPU exceptions.
The ManRiX microkernel doesn’t handle interrupt request in kernel space. It only acts as an IRQ redirector. For IRQ handling the User thread can register a handler for an IRQ. On the arrival of IRQ event, the Kernel finds the handler(s) for that IRQ and runs the handler. The IRQ is handled exactly as Signal Handler.

 
Memory Management:

The ManRiX Memory Manager is based in Mach’s VM design. The VM manager is divided into two parts, the machine dependent part called that Pmap and the machine independent part called the vmmap. This technique makes the portability easier to new architectures. MACH’s original VM system was designed on an object oriented manner. Its basic abstractions are represented by objects that are accessed by a well defined interface.

The highest level object is vm_map. A vmmap describes the virtual address space of a process or the kernel. It contains a list of valid mappings in the virtual address space and those mapping’s attributes. It holds a doubly linked list of vm_map_entries and a hint pointing to the last entry that resolved a page fault. Each vm_map_entry describes a contiguous region of virtual memory that has some protections. ManRiX Virtual Manager.


A vm_object represents a memory object. The memory object can be a set of physical pages or a memory mapped files. A vm_object describes a file, a zero-fill memory area, or a device that can be mapped into a virtual address space. The vm object contains a list of vm page structures that contain data from that object. The vm_page describes a page of physical memory. When the system is booted a vm page structure is allocated for each page of physical memory that can be used by the VM system.
The VM manager supports read/write sharing of memory and copy on write sharing of memory. The ManRiX VM manager uses a slab allocator (conceived by Solaris) to allocate kernel memory. following

Kernel pre-emption
ManRiX microkernel is a fully preemptible. It means that it is able to preempt the thread even if it is running in kernel mode. So, a highest priority thread starts running as soon as it becomes eligible to run. The Kernel preemption feature highly increases the responsiveness of the system and decreases the latencies. So, due to this characteristic ManRiX can also be used in real time systems.

Preemption can be disabled at critical section. The locks automatically disable kernel preemption and re enables them when lock is released. When the preemption is disabled, the interrupts are still enabled but the timer interrupt does not switch threads .

Symmetric multiprocessor(SMP)      

ManRiX microkernel has a multiprocessor support. For now, it supports Intel Multi Processors (MP) systems only. The number of Processors supported till now is eight. In SMP systems, Kernel Synchronization is a major issue. We overcome this issue using spin locks. The specialty of ManRiX microkernel is that the Interrupts are always enabled except in few situations like Interrupt redirection code. So, Spin locks don’t disable interrupts and thus the system is highly responsive. In ManRiX the Kernel code path is very short because the lengthy file system and device handler does not exist in microkernel. So, the mutex locks are not used.

 
 
   
             
©2005 ManRiX Project