Rtos Unit 1 Notes
Rtos Unit 1 Notes
ECPE2X15 3 0 0 3
COURSE OBJECTIVES:
● To expose the students to the fundamentals of interaction of OS with a computer and
User computation.
● To teach the fundamental concepts of how process are created and controlled with OS.
● To study programming logic of modeling Process based on range of OS features.
● To compare types and Functionalities in commercial OS, application development using
RTOS.
● To involve Discussions/ Practice/Exercise onto revising & familiarizing the concepts
acquired.
RTOS Architecture – RTOS Task and Task state, Process Synchronization, Message queues,
shared memory, Mail boxes, pipes, Critical section, Semaphores, mutex, priority inversion and
ceiling, circular and swinging buffers.
Process and Threads, Process Control Block, Process Attributes, Interrupt processing, memory
management, Priority based scheduling, Rate-Monotonic scheduling, Earliest Deadline first
scheduling
Principles, Kernel, Monolithic and Microkernel, Design issues, Polled Loop Systems, RTOS
Porting to a Target, Comparison and Basic study of various RTOS like VX works Linux
supportive RTOS.
Over view of Free RTOS – Architecture – Advanced Free RTOS concepts – Implementation of
Task Scheduling, Queue management, mutex, Semaphore with Free RTOS.
TOTAL : 45 PERIODS
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
FIG.1
Here we see the hardware at the bottom. The hardware consists of chips, boards,
disks, a keyboard, a monitor, and similar physical objects. On top of the hardware is
the software.
Most computers have two modes of operation: kernel mode and user mode.
The operating system, the most fundamental piece of software, runs in kernel mode
(also called supervisor mode).
FIG.2
• The User interface program Shell or GUI is the lowest level of user mode software.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
1. Process Management:
o Function: Manages the execution of processes, including task scheduling,
creation, termination, and synchronization.
o Example: Windows Task Manager allows users to view and manage running
processes.
2. Memory Management:
o Function: Manages the allocation and deallocation of memory space to
various programs to ensure efficient operation.
o Example: The use of virtual memory in operating systems like Windows and
Linux allows for more efficient memory usage.
3. File System Management:
o Function: Manages files on the storage devices, including file creation,
deletion, reading, writing, and permissions.
o Example: File Explorer in Windows provides a user interface to manage files
and directories.
4. Device Management:
o Function: Manages hardware devices by using device drivers to facilitate
communication between the OS and hardware.
o Example: Printers, keyboards, and network adapters are managed by the OS
to ensure they function correctly.
5. Security and Access Control:
o Function: Protects data and resources from unauthorized access and ensures
system security.
o Example: User authentication and permissions in Linux ensure that only
authorized users can access certain files and perform specific actions.
6. User Interface:
o Function: Provides a way for users to interact with the computer, either
through command-line interfaces (CLI) or graphical user interfaces (GUI).
o Example: The Windows desktop environment provides a GUI for easy
navigation and interaction with the system.
.
Fig.3
A modern general purpose computer system consist of one or more CPU’s and a
number of device controllers connected through a common bus that provides access
to shared memory.
Bootstrap Program : The initial program that runs when a computer is powered up or
Rebooted.
Stored in ROM
It must know the address of OS (Kernel) and how to load it and start executing that
system.
Interrupt :
• The occurrence of an even is usually signalled by an Interrupt from Hardware or
Software.
• Hardware may trigger an interrupt at any time by sending a signal to the CPU,
usually by the way of the system bus.
System Call :
• Software may trigger an interrupt by executing a special operation called system
call.
System/360:
IBM continued with backward-compatible successors: 370, 4300, 3080, 3090, and
zSeries.
System/360 used integrated circuits, providing cost-performance advantages.
Concept of compatible computer families adopted industry-wide.
OS/360 Challenges:
Timesharing Systems:
MULTICS:
Ambitious timesharing system developed by M.I.T., Bell Labs, and General Electric.
Introduced many seminal ideas despite limited commercial success.
With the development of LSI (Large Scale Integration) circuits—chips containing thousands
of transistors on a square centimeter of silicon—the age of the personal computer dawned. In
terms of architecture, personal computers (initially called microcomputers) were not all
that different from minicomputers of the PDP-11 class, but in terms of price they
certainly were different.
In 1974, Intel released the 8080, the first general-purpose 8-bit CPU.
Intel needed an operating system for the 8080 to facilitate testing.
Gary Kildall, a consultant for Intel, was tasked with writing the OS.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
2. Creation of CP/M:
Kildall, along with a friend, developed a controller for Shugart Associates' 8-inch
floppy disk.
They connected the floppy disk to the 8080, creating the first microcomputer with a
disk.
Kildall wrote the CP/M (Control Program for Microcomputers), a disk-based
operating system.
Intel, skeptical about the future of disk-based microcomputers, granted Kildall the
rights to CP/M.
Kildall founded Digital Research to develop and market CP/M further.
4. CP/M's Dominance:
In the early 1980s, IBM sought software for the IBM PC and contacted Bill Gates for
a BASIC interpreter and an operating system.
Gates suggested IBM contact Digital Research. Kildall's refusal to meet IBM and the
legal complications led IBM to return to Gates.
6. MS-DOS Development:
MS-DOS evolved with new versions and features, some inspired by UNIX.
The development of GUIs by researchers like Doug Engelbart and their adoption by
companies like Apple and Microsoft transformed user interfaces.
Microsoft's Windows initially ran on top of MS-DOS, later evolving into standalone
OS versions, influencing personal computing significantly.
Characteristics:
o Designed for applications requiring precise and deterministic response times.
o Guarantees deadlines are met consistently, critical for mission-critical systems.
o Typically minimalistic kernels to reduce overhead and ensure fast response.
o Examples include VxWorks, QNX, and FreeRTOS.
Applications:
o Used in industries like aerospace, automotive, medical devices, and industrial
automation.
o Tasks include control systems, robotics, process control, and real-time data
acquisition.
Characteristics:
o Optimized for resource-constrained embedded systems with limited memory
and processing power.
o Often tailored to specific hardware platforms, ensuring efficient utilization of
resources.
o Includes support for I/O handling, memory management, and device drivers.
o Examples include Embedded Linux distributions, Windows Embedded
Compact, and Android (for embedded systems).
Applications:
o Found in diverse embedded devices such as smartphones, digital cameras,
consumer electronics, and IoT devices.
o Provides operating environments for various applications requiring reliability,
performance, and specific functionalities.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
Comparison:
Scope of Use:
o RTOS focuses on real-time responsiveness and deterministic behavior, critical
for applications with strict timing requirements.
o Embedded OSes target a broad range of embedded systems, offering
flexibility and scalability across different hardware platforms and applications.
Resource Management:
o RTOS emphasizes minimalism and efficient resource management to meet
real-time constraints.
o Embedded OSes optimize resource utilization and performance within the
constraints of embedded hardware.
Development and Deployment:
o RTOS requires specialized knowledge in real-time computing and often
involves rigorous testing and certification processes.
o Embedded OSes support development with standard tools and frameworks,
accommodating diverse development environments and application domains.
Key Differences:
o RTOS prioritizes deterministic behavior and real-time responsiveness,
ensuring tasks are completed within specific deadlines.
o Embedded OSes offer broader flexibility and support for various applications
beyond real-time constraints, leveraging general-purpose features and
ecosystem support.
Introduction:
Function: The CPU is the brain of the computer, responsible for executing
instructions and processing data.
Recent Advancements:
o Multicore Processors: CPUs now come with multiple cores, allowing for
parallel processing and multitasking.
Memory:
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
Cache memory:
Memory (RAM):
Function: Random Access Memory (RAM) provides temporary storage for data and
instructions that the CPU needs to access quickly.
Recent Advancements:
o Increased Capacity and Speed: Modern RAM modules offer higher
capacities (e.g., 32GB, 64GB) and faster speeds (e.g., DDR4, DDR5).
o Lower Latency and Power Consumption: Improvements in latency and
power efficiency (e.g., LPDDR4X for mobile devices).
Impact: Faster data access and processing, improved multitasking capabilities, and
better performance for memory-intensive applications.
Storage Devices:
Function: Storage devices retain data and software programs permanently or semi-
permanently.
Recent Advancements:
o Solid-State Drives (SSDs): Faster read/write speeds and lower latency
compared to traditional Hard Disk Drives (HDDs).
o Non-Volatile Memory Express (NVMe): NVMe SSDs use PCIe interfaces
for even higher data transfer rates.
Impact: Quicker boot times, faster file access, and overall enhanced system
responsiveness.
Function: The GPU handles rendering of images, videos, and animations, and can be
used for parallel processing tasks.
Recent Advancements:
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
Input/Output Devices:
Function: Input devices (e.g., keyboard, mouse) allow users to interact with the
computer, while output devices (e.g., monitors, printers) display results.
Recent Advancements:
o High-Resolution Displays: 4K and 8K monitors with high refresh rates for
smoother visuals.
o Ergonomic and Wireless Peripherals: Improved design for user comfort and
convenience.
Impact: Better user experience, enhanced productivity, and more immersive
interactions.
• Processes
• Address spaces (memory)
• Files
Processes :
Child processes:
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
• If a process can create one or more other processes and these processes in turn can
create child processes.
•
• Inter-process communication: Related processes that are cooperating to get some
job done often need to communicate with one another and synchronize their
activities. This communication is called inter-process communication.
• Release unused memory.
• The operating system sets an Alarm signal to the process.
Address Spaces:
Every computer utilizes main memory to execute programs. Simple operating systems
handle one program at a time, requiring memory swaps for additional programs.
More advanced systems allow multiple programs in memory simultaneously,
necessitating protection mechanisms managed by the operating system to prevent
interference.
An essential aspect of memory management is addressing the processes' address
spaces.
Each process typically has a range of addresses it can use, which may exceed the main
memory capacity.
Initially, processes with larger address spaces than available memory were
unsupported.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
Modern systems use virtual memory, where the operating system shuttles parts of the
address space between main memory and disk, creating an abstraction that decouples
address space from physical memory size.
This allows address spaces to be larger or smaller than physical memory.
Files:
• Every file within the directory hierarchy can be specified by giving its path
name from the top of the directory hierarchy, the root directory.
• From Fig, the path for file CS101 is /Faculty/Prof.Brown/Courses/CS101.
• The leading slash indicates that the path is absolute, that is, starting at the root
directory.
• At every instant, each process has a current working directory, in which path names
not beginning with a slash are looked for.
• Processes can change their working directory by issuing a system call specifying the
new working directory.
• Before a file can be read or written, it must be opened, at which time the permissions
are checked.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
• If the access is permitted, the system returns a small integer called a file descriptor to
use in subsequent operations. If the access is prohibited, an error code is returned.
• Special files:
• Special files are provided in order to make I/O devices look like files. That way, they
can be read and written using the same system calls as are used for reading and
writing files.
• Two kinds of special files exist: block special files and character special files.
• Pipe :
• A pipe is a sort of pseudo-file that can be used to connect two processes, as shown in
Fig.
• If processes A and B wish to talk using a pipe, they must set it up in advance. When
process A wants to send data to process B, it writes on the pipe as though it were an
output file.
• In fact, the implementation of a pipe is very much like that of a file. Process B can
read the data by reading from the pipe as though it were an input file.
• Control switches from user mode to kernel mode to access the resource to execute the
process through TRAP instruction.
• System call is the programmatic way in which a computer program requests a service
from the kernel of the operating system.
Example:
• The system call (and the library procedure) return the number of bytes actually
read in count.
• If the system call cannot be carried out owing to an invalid parameter or a disk error,
count is set to −1.
• Calling the read library procedure, which actually makes the read system call,
• Step 1 to 3 : The calling program first pushes the parameters( file, address of buffer,
no of bytes) onto the stack.
The first and third parameters are called by value, but the second parameter is passed
by reference, meaning that the address of the buffer (indicated by &) is passed, not the
contents of the buffer.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
• Step 4 : This instruction is the normal procedure-call instruction used to call all
procedures.
• Step 5 : The library procedure, possibly written in assembly language, typically
puts the system-call number in a place where the operating system expects it, such as
a Register.
• step 6 : Then it executes a TRAP instruction to switch from user mode to kernel mode
and start execution at a fixed address within the kernel.
• Step 7 : The kernel code that starts following the TRAP examines the system-call
number and then dispatches to the correct system-call handler, usually via a
table of
• pointers to system-call handlers indexed on system-call number.
• Step 8: At that point the system-call handler runs.
• Step 9: Once it has completed its work, control
• may be returned to the user-space library procedure at the instruction following the
TRAP instruction .
• Step 10: This procedure then returns to the user program in the usual way procedure
calls return .
• Step 11: To finish the job, the user program has to clean up the stack, as it does after
any procedure call .
• Process management
• File management
• Directory management
• Miscellaneous system calls
Process management:
• To wait for the child to finish, the parent executes a waitpid system call, which just
waits until the child terminates.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
• It reads a command from the terminal , waits for the child to execute the
command, and then reads the next command when the child terminates.
• waitpid(pid, &statloc, options): It has three parameters.
File management:
purpose : create file, delete file open ,close , read, and write .
To read or write a file, it must first be opened. This call specifies the file name to be
opened, either as an absolute path name or relative to the working directory,
Directory management:
s = link(name1, name2).
chdir call --- changes the current working directory. After the call
chdir("/usr/ast/test");
The concept of a working directory eliminates the need for typing (long) absolute path
names all the time.
makes it possible to change the mode of a file. For example, to make a file read only by
everyone except the owner, one could execute.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
1. Monolithic systems.
2. Layered systems.
3. Microkernels.
4. Client – server model.
5. Virtual machines.
Monolithic systems:
• In addition to the core operating system that is loaded when the computer
is booted, many operating systems support loadable extensions, such
as I/O device drivers and file systems.
• These components are loaded on demand. In UNIX they are called
shared libraries.
• In Windows they are called DLLs (Dynamic-Link Libraries).
Layered systems:
deal with abstract I/O devices with nice properties, instead of real devices
with many peculiarities.
Layer 4 was where the user programs were found. They did not have to
worry about process, memory, console, or I/O management.
The system operator process was located in layer 5.
Example : the layering concept was present in the MULTICS system.
Microkernels:
• With the layered approach, the designers have a choice where to draw the
kernel-user boundary.
• Traditionally, all the layers went in the kernel, but that is not
necessary.
• In fact, a strong case can be made for putting as little as possible in kernel
mode because bugs in the kernel can bring down the system instantly.
• In contrast, user processes can be set up to have less power so that a bug
there may not be fatal.
• A monolithic operating system of five million lines of code is likely to
contain between 10,000 and 50,000 kernel bugs.
• The basic idea behind the microkernel design is to achieve high reliability
by splitting the operating system up into small, well-defined
modules, only one of which—the microkernel—runs in kernel mode
and the rest run as relatively power less ordinary user processes.
• In particular, by running each device driver and file system as a separate
user process, a bug in one of these can crash that component, but cannot
crash the entire system.
• Thus a bug in the audio driver will cause the sound to be garbled or
stop, but will not crash the computer.
• In contrast, in a monolithic system with all the drivers in the kernel, a
buggy audio driver can easily reference an invalid memory address
and bring the system to a grinding halt instantly
• A few of the better-known microkernels include Integrity, K42, L4,
PikeOS, QNX, Symbian, and MINIX 3.
• The MINIX 3 microkernel is only about 12,000 lines of C and some 1400
lines of assembler for very low-level functions such as catching interrupts
and switching processes.
• The C code manages and schedules processes, handles interprocess
communication (by passing messages between processes), and offers a set
of about 40 kernel calls to allow the rest of the operating system to do its
work.
Chennai Institute Of Technology REAL TIME OPERATING SYSTEM ECE DEPARTMENT
The device driver for the clock is also in the kernel because the
scheduler interacts closely with it. The other device drivers run as
separate user processes.