A multitasking operating system proposed for real-time applications is known as real-time operating system.
The applications comprise embedded systems like programmable thermostats, household appliance controllers, industrial robots, mobile telephones, scientific research equipment and spacecraft, industrial control.
A real-time operating system provides the design of a real-time system, but does not ensures the real time of the final outcome as it needs proper growth of the software.
A real-time operating system does not possesses high through put; rather, a real-time operating system provides, assurance deadlines that can be met generally like soft real-time or deterministically like hard real-time.
Real-time operating system characteristically utilizes specific scheduling algorithms in order to facilitate the real-time developer with the device required to generate deterministic performance in the final system.
Real-time operating system is valued more for its fastness and predictably as it can retort to a meticulous event for the given amount of work it can execute over time.
Main issues in a real-time operating system are smallest interrupt latency and a least thread switching latency.
An initial example of a large-scale real-time operating system was termed as "control program" which was established by American Airlines and IBM for the Sabre Airline Reservations System.
Two basic designs
Event-driven or priority preparation designs switch tasks only when an event of higher precedence requires service termed as pre-emptive priority.
Time-sharing designs switch chores on a clock interrupt, and on events known as round robin.
Time-sharing creates switch tasks more frequently than strictly required but provide smoother, more deterministic multitasking, offering the delusion that a procedure or user boasts exclusive usage of a machine.
Initially CPU designs are required for various cycles to switch tasks, during which the CPU could not perform anything functional.
Thus the operating systems tried to lessen wasting CPU time by maximally evading needless task-switches.
Recent CPUs obtain far less time to switch from one task to another.
The extreme case is barrel processors that switch from one task to the next in zero cycles.
Latest real-time operating systems almost perpetually implement time-sharing scheduling with priority driven pre-emptive scheduling.
Intertask communication and resource sharing
Multitasking systems can handle data sharing and hardware resources among multiple tasks.
It is usually "perilous" for two tasks to access the similar specific data or hardware resource simultaneously.
There are three general approaches to resolve this problem:
Temporarily masking or disabling interrupts
General purposes of operating systems do not permits user programs to disable or interrupt, because the user program can control the CPU for a longer time as it wished.
The interrupt disable control bit is made inaccessible in user mode by modern CPUs to endow with the operating systems to check user tasks from doing this.
Various embedded systems and real-time operating system permits the application itself to run in kernel mode for greater system call competence and also to allow the application to possess huge control of the operating environment without needing an operating system for intervention.
If the application runs in kernel mode and can camouflage interrupts on single-processor systems.
This is the finest solution to prevent simultaneous access to a shared resource.
While interrupts are cloaked, the current task has exclusive use of the CPU.
When the task egresses its vital section, it must expose interrupts.
Provisional camouflaging interrupts should be performed when the highest course through the vital section is smaller than the desired greatest interrupt latency.
Characteristically the procedure of protection is utilized only when the vital section is just a few source code lines long and contains no loops.
This procedure is perfect for protecting hardware bitmapped registers when the bits are controlled by diverse tasks.
When the vital section is greater than a few source code lines or engrosses long looping, an embedded or real-time programmer must become a remedy to utilize mechanisms alike or parallel to those obtainable on common purpose operating systems, such as semaphores and operating system supervised interprocess messaging.
Such mechanisms engage system calls, and generally summon to the operating system’s dispatcher code on outlet.
So they can take many hundreds of CPU instructions to perform, while camouflaging interrupts may take as few as three instructions on some processors.
But for longer vital sections selection is not provided as interrupts cannot be camouflaged long periods without increasing the interrupt latency of the system.
A binary semaphore may be locked or unlocked.
A line of tasks waits for the semaphore when it is locked.
Characteristically a timeout on its wait for a semaphore is done by a task.
A characteristic solution is to boast the task that has a semaphore run at the priority of the highest waiting task.
But the simplistic loom fails when there are multiple levels of waiting like A waits for a binary semaphore locked by B, which waits for a binary semaphore locked by C.
Managing multiple levels of legacy without launching instability in cycles is not straightforward.