Before I started my first project two years ago, I admit that I did not know much about working with a (real-time) operating system. All the stuff like – counting semaphores, task scheduling, context switches, event control blocks, interrupts and ISR routines, task and time management, and what else seemed too much to grasp.
The only thing I could think about when someone said Operating System before was a Windows or a Linux OS…and boy, it was blissful ignorance! As I started to write code for the first embedded system, I realized how naive I had been to think that I could always stick to Windows or a Linux machine and write small software programs and stay afloat.
As it dawned on me that this would not be the case in my new company, I began searching to learn what an RTOS (aka, Real-Time Operating System) could do and how it worked. It took me a while and a lot of effort to finally understand why we needed one and what all one could do. But I do not regret the time spent learning all that I could find on the topic. Even now, I am not as naive and ignorant as before.
So I should note it all down somewhere, maybe for future reference or just for anyone who wanted a quick feel or glimpse at what a real-time OS was needed for or could do.
Chapter 1. RTOS – Fundamentals
To start, An RTOS is a multitasking operating system intended for real-time applications, mostly those running on embedded systems. The list of embedded systems we find daily keeps growing exponentially yearly. Nowadays, you find embedded systems everywhere, be it household appliances- like microwaves, dishwashers, office appliances – like fax machines or copiers, computer peripherals – like modems, printers, scanners, or hi-tech stuff like robots, spacecraft, automobiles, research equipment, weapons systems, and whatnot.
The RTOS that I got to work with was called PCOS-II from Micrium. The Basic con
READ MORE :
- Most (and Least) Time Consuming Game Genres
- What Constitutes Separate Property in Virginia?
- Choosing The Right Property And Investment Style
- A Prescription For the Healthcare Crisis
- Mobile Media Mania
Acceptors that one has to know about before starting with an RTOS are – Resources A resource simple means any entity, for example, an I/O device like a keyboard, display, printer, or a program defined array, variable, or structure. Tasks A task or a thread, as some may call it, is just a simple program that thinks it has all the resources and CPU to itself. A study can typically have any of these states – Running, Dormant, Ready, Waiting. A job is said to run when it has control and can execute its code. A job is said to be ready to execute its code, but its priority is lesser than the currently running task. An appointment is displayed to be waiting when it is waiting for an event like an Input/Output operation to complete, an interrupt to occur, or any resource to become available. A task is dormant when it still resides in the memory and has not been made available to the kernel.
Multitasking Multitasking is the process by which several tasks or threads can run on the same CPU. Better said is it is id when a single CPU switches its attention between various tasks in a secure, sequentially, someone to think that all the jobs are being run simultaneously. Switches or Task Switches This is when a kernel shifts its attention to a different position from the one it is currently executing. To enable context switches, the seed must safely save all the running tasks’ CPU registers onto the stack and then load all the saved registers of the next task waiting to be run. Kernel The Kernel is the central component of the Operating system, and it manages all the charges. Its main job is to enable the context switches or task switches. Its responsibilities also include managing the various system resources.
- Schedulers
- First in First Out
- Round Robin
- Shortest Remaining Time
- Priority Based
The Scheduler is the part of the Kernel responsible for determining which of the current tasks have to be run next. Two types of priority-based kernels exist – the preemptive ones and the non-preemptive ones.
Non-preemptive scheduling is also called cooperative multitasking; the tasks cooperate to share the CPU and give the illusion that all of them execute simultaneously. Each task works for some time, giving the CPU control over the other functions.
The preemptive one always runs the highest priority task, which is ready to run. When a higher priority task becomes ready to run, the current study is pre-emptied ( or suspended), and the CPU control is given to the new higher priority task. Once the higher-priority task has finished execution, the CPU control is transferred back to the earlier study, which was suspended.