From Digital Systems
Jump to: navigation, search

micro:bian is a very simple operating system for embedded devices, supporting families of independent processes that communicate by passing messages, and are scheduled non-preemptively. The inter-process communication mechanism is loosely based on that provided by Minix, a lightweight implementation of Unix written by Andrew Tanenbaum and others.

micro:bian presently runs on ARM-based microcontrollers, especially the BBC micro:bit and otheres supported by the MBED platform, though micro:bian and the MBED libraries share no code. It is written mostly in C, supported by fragments of assembly language for process switching. Another page has unix-style manual pages for each system call, and yet another gives details of the device drivers provided for peripherals on the micro:bit board.

(Copy overview from Introducing micro:bian chapter of the book.)

Other system calls

A process may call yield() in order to pause voluntarily and allow other processes to run.

void yield(void);

Calls to yield should not be needed even in long-running processes, because they will be suspended automatically when an interrupt arrives. However, yield is used internally in micro:bian to invoke the process scheduler when the system starts.

A process may call exit() to suspend itself in such a way that it will never run again.

void exit(void);

A call to exit implicitly follows the function call that forms the body of a process, so that it the function returns, the process exits just as if exit() had been called as its last action.

Each process has a priority between 0 and 3, with 0 (the most urgent) reserved for processes connected to interrupts, and priority 3 (the least urgent) reserved for the idle process. Other processes can set their own priority to 1 or 2 by calling setprio(p).

void setprio(int prio)

The allowable priorities are HI_PRIO = 1 and LO_PRIO = 2. Processes that are not connected to interrupts have priority 2 by default. In some programs, it is possible to improve responsiveness by setting the priority to 1 for carefully selected processes that respond to events, leaving long-running background processes at priority 2.




The standard UART driver process calls dump when you type Ctrl-B on the keyboard.