Rtos Unit III Notes
Rtos Unit III Notes
Event Based – Process Based and Graph based Models – Real Time
Languages – RTOS Tasks – RT scheduling - Interrupt processing –
Synchronization – Control Blocks – Memory Requirements.
The source of an event can be from internal or external inputs. Events can
generate from a user, like a mouse click or keystroke, an external source,
such as a sensor output, or come from the system, like loading a program.
Pub/sub model
This is a messaging infrastructure based on subscriptions to an event stream.
With this model, after an event occurs, or is published, it is sent to subscribers
that need to be informed.
Events are captured as they occur from event sources such as Internet of
Things (IoT) devices, applications, and networks, allowing event
producers and event consumers to share status and response information
in real time.
Today, almost every computers can do many things at the same time. For
instance, you can download files from Internet, operate your Facebook
account, copy some songs to the pen drive, all can be perform at the same
time. This is called multitasking.
In process model, all the runnable software on the computer, is organized
into a number of sequential processes. Each process has its own virtual
Central Processing Unit (CPU).
The real Central Processing Unit (CPU) switches back and forth from
process to process. This work of switching back and forth is
called multiprogramming.
Process Creation:
There are the following four principal events that cause the processes to be
created.
System initialization
Execution of a process creation system call by a running process
A user request to create a new process
Initiation of a batch work.
Generally, there are some processes that are created whenever an operating
system is booted. Some of those are foreground processes and others are
background processes.
Foreground process is the process that interact with the computer users or
computer programmers.
In addition to the processes that are created at the boot time, new
processes can also be created.
Sometime a running process will issue the system calls just to create one or
more than one new processes to help it to do its work.
Process Termination:
When a process has been created, it starts running an does its work.
The new process will terminate generally due to one of the following
conditions, described in the table given below.
Condition Description
Fatal exit In fatal exit, process terminates because it discovers a fatal error
Whenever a computer user sends a signal from the keyboard, that signal
is then delivered to all the members of the process group that are
currently associated with the keyboard.
OS Process States:
Since each process is an independent entity with its own program counter
and internal state, processes sometime need to interact with other
processes.
The diagram given below (state diagram) shows all the three states.
In these three states, a process may be in.
Running
Ready
Ready tasks are those that are able to execute (they are not in the
Blocked or Suspended state) but are not currently executing because a
different task of equal or higher priority is already in the Running state.
Blocked
Tasks in the Blocked state do not use any processing time and cannot be
selected to enter the Running state.
Suspended
Like tasks that are in the Blocked state, tasks in the Suspended
state cannot be selected to enter the Running state, but tasks in the
Suspended state do not have a time out. Instead, tasks only enter or exit
the Suspended state when explicitly commanded to do so through the
vTaskSuspend() and xTaskResume() API calls respectively.
Real-time systems are systems that carry real-time tasks. These tasks
need to be performed immediately with a certain degree of urgency. In
particular, these tasks are related to control of certain events (or) reacting to
them. Real-time tasks can be classified as hard real-time tasks and soft real-
time tasks.
A hard real-time task must be performed at a specified time which could
otherwise lead to huge losses. In soft real-time tasks, a specified deadline can
be missed. This is because the task can be rescheduled (or) can be completed
after the specified time,
If a preemptive scheduler is used, the real-time task needs to wait until its
corresponding tasks time slice completes. In the case of a non-preemptive
scheduler, even if the highest priority is allocated to the task, it needs to wait
until the completion of the current task. This task can be slow (or) of the lower
priority and can lead to a longer wait.
INTERRUPT PROCESSING:
The operating system analyses the interrupt and passes control to the
appropriate routing to handle the interrupt.
The interrupt handler routine processes the interrupt.
The state of the interrupted process is restored.
The interrupted process executes.
An interrupt may be initiated by a running process called a trap and said to be
synchronous with the operation of the process or it may be caused by some
event that may or may not be related to the running process it is said to be
asynchronous with the operation of the process.
INTERRUPT CLASSES:
These are initiated by a running process that execute the svc is a user generated
request for a particular system service such as performing input/output,
obtaining more storage, or communicating with the system operator.
* I/O interrupts:
These are initiated by the input/output hardware. They signal to the cpu that the
status of a channel or device has changed. For eg., they are caused when an I/O
operation completes, when an I/O error occurs.
* External interrupts:
* Restart interrupts:
These occur when the operator presses the restart button or arrival of restart
signal processor instruction from another processor on a multiprocessor system.
* Program check interrupts:
These may occur when a programs machine language instructions are executed.
These problems include division by zero, arithmetic overflow or underflow,
data is in wrong format, attempt to execute an invalid operation code or attempt
to refer a memory location that do not exist or attempt to refer protected
resource.
Synchronization:
Synchronization and messaging provides the necessary communication
between tasks in one system to tasks in another system. The event flag is
used to synchronize internal activities while message queues and
mailboxes are used to send text messages between systems. Common
data areas utilize semaphores.
In general, a task must synchronize its activity with other tasks to execute
a multithreaded program properly. Activity synchronization is also
called condition synchronization or sequence control . Activity
synchronization ensures that the correct execution order among
cooperating tasks is used. Activity synchronization can be either
synchronous or asynchronous.
Memory Management
Memory Management is the process of controlling and coordinating
computer memory, assigning portions known as blocks to various
running programs to optimize the overall performance of the system.
Uses:
Partitioned Allocation
This method divides the computer's main memory into fixed-size units
known as page frames. This hardware memory management unit maps pages
into frames which should be allocated on a page basis.
Segmented Memory Management
What is Swapping?
Backing store is a hard disk or some other secondary storage device that
should be big enough inorder to accommodate copies of all memory images for
all users. It is also capable of offering direct access to these memory images.
Benefits of Swapping:
Partition Allocation:
1. First Fit: In this type fit, the partition is allocated, which is the
first sufficient block from the beginning of the main memory.
2. Best Fit: It allocates the process to the partition that is the first
smallest partition among the free partitions.
3. Worst Fit: It allocates the process to the partition, which is the
largest sufficient freely available partition in the main memory.
4. Next Fit: It is mostly similar to the first Fit, but this Fit, searches
for the first sufficient partition from the last allocation point.
What is Paging?
What is Fragmentation?
Processes are stored and removed from memory, which creates free
memory space, which are too small to use by other processes.
1. External fragmentation
2. Internal fragmentation
Static loading is used when you want to load In a Dynamically loaded program, referenc
your program statically. Then at the time of will be provided and the loading will be do
compilation, the entire program will be linked at the time of execution.
and compiled without need of any external
module or program dependency.
At loading time, the entire program is loaded Routines of the library are loaded into mem
into memory and starts its execution. only when they are required in the program
Static linking is used to combine all other When dynamic linking is used, it does not n
modules, which are required by a program into to link the actual module or library with the
a single executable code. This helps OS program. Instead of it use a reference to the
prevent any runtime dependency. dynamic module provided at the time of
compilation and linking.