&
Advertise Here with Today.com
 

Aug 17 2009

Writing a Small Operating System

Published by impomatic at 9:35 am under Programming Edit This

I’ve just rediscovered a project I started in 1997 and have always intended to go back and complete one day. The project is a small operating system suitable for microcontrollers.

The OS will provide the following functionality, similar to a MicroKernel:

  • memory management (done)
  • preemptive task switching (done)
  • process management (done)
  • inter process communication

Memory Management

Memory is divided into variable size block, each preceded by a small memory control stucture. The structure contains the following:

  • link to previous block
  • link to next block
  • link to owner of block
  • length of block
  • in use flag: is this block available?
  • ready flag: is process ready to execute?
  • stack pointer: sp saved when not active

Functions to allocate / free memory are provided. Have I missed anything important?

Task Switcher

The task switcher is called by the timer interrupt and switches to the next available task. Switching is disabled while memory is being allocated / freed.

Process Management

Functions are provided to create new processes, kill processes, mark a process as available or blocked. Switching is disabled while processes are being manipulated.

Inter Process Communication

Semaphores and message passing will be implemented. Unfortunately, I stumbled across a problem. How do I get two processes to agree which semaphore / message to use?

Should they be numbered, named or referred to by an address in memory? Should a semaphore / message buffer be allocated to each process or block of memory? If named, how should I handle name collisions?

Any advice on implementing IPC would be appreciated.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • TwitThis
Possibly-related Articles:                                        (auto-generated)
Advertise Here with Today.com

Trackback URI | Comments RSS

Leave a Reply

Advertise Here