Operating systems are complex programs that interface hardware with user programs. Some modules that make up an operating system are the scheduler, dispatcher, context switch, memory manager, inter-process communication module, real-time clock manager, interrupt manager, and file system manager.
Scheduler is to select a process from among those ready to run, schedule time for it on the CPU, and maintain a list of ready processes.
Dispatcher dispatches jobs to the CPU, using the list created by the scheduler
Control Structures in Real Time Systems
Polling loop - Program polls or sends some signals to the device to check if its state is changed , on state change it performs an action. Eg. Refridgerator tempreature control
Event Driven - Program ( loop ) waits till an interrupt occurs / message from the device , on interrrupt the program stops services the interrupt then continues
a. Foregound/Background - Is basically polling loop with interrupt enabled
b. Multitasking - CPU time slicing is allocated by OS to different tasks
c. Multiprocessor
Synchronous - Sender waits for the message to be processed . Maintains a clock to synchronise
Asynchronous - Sender proceeds irrespective of the receiver. No clock
Interrupts - Real time processors have one or more interrupr req. lines (IRQ) to connect to peripherals. When a peripheral wants CPU . it asserts IRQ. This is asyn. CPU services the request , the current task is preempted. ProgramCounter PC , Registers are stored in stack and a jump is made to location of ISR. When ISR finished state of the processor is restored and program continues.
Data Structures in Real Time Systems
Traps - are not the same as interrupts, but they are usually handled the same way. Interrupts and asynchronous events are externally caused while traps are considered synchronous even though they are unexpected. Traps usually result from software errors.
Semaphore, invented by Edsger Dijkstra1, is used to coordinate processes and shared resources. There are two types of semaphores: binary and counting. A binary semaphore is used to provide mutual exclusion. A counting semaphore is used when a resource can be used by more than one task at a time [13]. The basic counting type is an integer variable that is accessed only through two basic operations, wait and signal; however, an initialize operation is also usually provided. Modifications to the integer value of the semaphore must be executed without interruption.
Macro is a label that replaces a block of instructions that is used more than once, but only coded once. It differs from a subroutine in that the assembler inserts the code where the call is made rather than having a jump-to-it command. It works by text substitution and is usually faster than a subroutine but takes up more memory.
Pipe is a stream of data used to connect tasks, or to provide task communication. A buffer, like a first-in-first-out buffer, can implement it. This eliminates the need to use a file to store temporary results. A pipe self-regulates its flow so that it uses less disk space than a temporary file [14].
Script is a file of characters used for input or instructions to a program. The programmer can use it to simulate an interactive user or other I/O device. A script file could be a list of commands for a command interpreter such as a batch file [15].
Process is a execution of a program and program contain set of instructions
Thread is a single sequence stream within the process.thread is sometime called lightweight process.
In most multithreading operating systems, a process gets its own memory address space; a thread doesn't. Threads typically share the heap belonging to their parent process.
Pre-emptive multitasking involves the use of a scheduler which hands out CPU time to various processes so that they can be performed simultaneously. Therefore all processes will get some amount of CPU time at any given time.
Starvation - If higher priority tasks keep a lower priority task from running, the condition is called Starvation
Predictability is extremely important in real-time programming, and to get it, you need to keep track of time.
Response time is the time it takes the computer to recognize and respond to an external event.
Survival time is the time during which the data will be valid.
Throughput is the number of events that the system can handle in a given time period [20].
Advanced C Programming - A good description of C language used to control hardware like motors
Object Orientation in C language
Real Time Application Development
1. http://www.eventhelix.com/RealtimeMantra/IssuesInRealtimeSystemDesign.htm
2. http://www.stsc.hill.af.mil/Crosstalk/2003/11/0311Ludwig.html ( Good starting point )