Eosdd U1
Eosdd U1
10211EC201
Unit – 1, OVERVIEW OF RTOS
• CO1.a: Explore the basic concepts of operating system and RTOS objects. - K2
• CO1.b: Develop and simulate RTX51 based embedded OS code for 8051
microcontroller using Keil IDE and report on the code execution statistics by
identify the time-consuming module for optimization. -S3
UNIT I OVERVIEW OF RTOS
1. Introduction to OS. 7. Inter Process Communication.
2. OS Structure. • Message Queues,
• Mailboxes,
3. System Calls. • Pipes.
4. RTOS Task and Task State. 8. Critical Section.
5. Scheduling. 9. Semaphores.
• Preemptive
• Non-preemptive. 10. Classical Synchronization
Problem - Deadlocks.
6. Process Synchronization.
Introduction
UNIT I OVERVIEW OF RTOS
1. Introduction to OS (Operating System):
• An operating system is software that acts as an intermediary between
computer hardware and the computer user.
• It provides services and resources to applications, manages hardware
resources, and facilitates communication between software and
hardware components.
2. OS Structure:
• Operating systems are typically structured in layers, with each layer
serving a specific purpose.
• Common layers include the kernel (core functionality), device drivers
(interface with hardware), and user interface.
3. System Calls:
• System calls are interfaces provided by the operating system that
allow applications to request services such as file operations, process
control, and memory allocation.
4. RTOS Task and Task State:
• Real-Time Operating Systems (RTOS) are designed for applications
with strict timing requirements.
• Tasks represent the basic units of work in an RTOS, and their states
(e.g., ready, running, blocked) determine their execution status.
5. Scheduling.
(Preemptive and Non-preemptive):
• Scheduling involves deciding which tasks should run and for how
long.
• Preemptive scheduling allows tasks to be interrupted.
• Non-preemptive scheduling completes a task before allowing another
to start.
6. Process Synchronization:
• Process synchronization ensures that multiple tasks or processes can
coordinate and share resources without conflicts.
• This is crucial for preventing data corruption and ensuring proper
operation.
7. Inter Process Communication (IPC):
• IPC mechanisms facilitate communication between different tasks or
processes.
• Examples include message queues, mailboxes, pipes, and shared
memory.
8. Critical Section:
• A critical section is a part of the code where shared resources are
accessed, and only one task should execute it at a time to avoid data
corruption.
9. Semaphores:
• Semaphores are synchronization objects used to control access to
shared resources.
• They can be used to implement mutual exclusion and coordination.
10. Classical Synchronization Problem -
Deadlocks:
• Deadlocks occur when two or more tasks are unable to proceed
because each is waiting for the other to release a resource.
Content
UNIT I OVERVIEW OF RTOS
1. Introduction to OS (Operating System):
• Definition of an Operating System • Types of Operating Systems.
(OS) • Single-User, Single-Task
• Purpose and Functions. • Single-User, Multi-Task
• Resource Management • Multi-User
• Abstraction • Real-Time Operating System (RTOS)
• User Interface • Examples of Operating Systems.
• Services Provided by the • Microsoft Windows
Operating System. • macOS
• Process Management • Linux
• Memory Management • Unix
• File System Management • Evolution of Operating Systems.
• Device Management • Importance of Operating Systems.
• Security and Protection
• User Interface Services
1. Introduction to OS -
1.1 Definition of an Operating System (OS):
• An operating system is a specialized software that manages computer
hardware and provides services for computer programs.
• It serves as an intermediary between the user and the computer
hardware, making it easier for users to interact with computers.
1. Introduction to OS -
1.2 Purpose and Functions:
• Resource Management:
• The OS manages computer resources, including CPU time, memory space, file
storage, and peripheral devices.
• It allocates resources efficiently among various applications and users.
• Abstraction:
• The OS abstracts the complex hardware details from applications.
• It provides a standardized interface (system calls) that allows software to interact
with the hardware without needing to understand its intricacies.
• User Interface:
• Operating systems often provide a user interface, which can be command-line-based
or graphical.
• This interface allows users to interact with the computer system through commands
or graphical elements.
1. Introduction to OS -
1.3 Services Provided by the Operating System:
• Process Management:
• The OS manages processes, which are instances of executing programs.
• It includes process scheduling, creation, termination, and communication
between processes.
• Memory Management:
• The OS allocates and deallocates memory space as needed by programs.
• It also implements virtual memory, allowing processes to use more memory
than physically available.
• File System Management:
• Operating systems organize and manage files on storage devices.
• This involves file creation, deletion, reading, and writing.
1. Introduction to OS -
1.3 Services Provided by the Operating System:
• Device Management:
• The OS communicates with hardware devices, such as printers, disk drives, and
network interfaces.
• It provides a uniform interface for application programs to interact with these
devices.
• Security and Protection:
• The OS enforces security measures to protect data and resources from unauthorized
access.
• It also ensures that one process cannot interfere with the execution of another.
• User Interface Services:
• Operating systems provide user interfaces, which can be command-line interfaces
(CLI) or graphical user interfaces (GUI).
• This allows users to interact with the computer system.
1. Introduction to OS -
1.4 Types of Operating Systems:
• Single-User, Single-Task:
• Designed for a single user and can handle only one task at a time.
• Single-User, Multi-Task:
• Allows a single user to execute multiple tasks concurrently.
• Multi-User:
• Supports multiple users simultaneously, each with their own tasks and
processes.
• Real-Time Operating System (RTOS):
• Designed for applications with strict timing requirements, such as embedded
systems and control systems.
1. Introduction to OS -
1.5 Examples of Operating Systems:
• Microsoft Windows:
• Widely used in personal computers and laptops.
• macOS:
• The operating system for Apple Macintosh computers.
• Linux:
• An open-source operating system kernel used in various distributions (distros)
like Ubuntu, Fedora, and Debian.
• Unix:
• A powerful and versatile operating system used in servers and workstations.
1. Introduction to OS -
1.6 Evolution of Operating Systems:
• Operating systems have evolved from simple batch processing
systems to interactive systems, and now to distributed and cloud-
based systems.
1. Introduction to OS -
1.7 Importance of Operating Systems:
• Operating systems form the backbone of computing systems,
providing a platform for software applications to run and interact with
hardware.
• They enable users to harness the power of computers without dealing
with the complexities of hardware management.
1. Introduction to OS – Summary:
• An operating system plays a crucial role in managing computer
resources, providing services to applications, and facilitating a user-
friendly interface for efficient interaction with the computer system.
• It serves as a vital component that enables the effective use of
computer hardware and software.
2. Operating System Structure:
2.1 OS Structure: 2.2 Benefits of Layered OS
• Kernel Structure:
• Device Drivers • Modularity
• File System • Abstraction
• User Interface • Scalability.
• System Libraries
• Application Programs
2. OS Structure –
2.1 Kernel:
• The kernel is the core component of the operating system. It provides
essential services and manages the most fundamental operations of
the computer.
• Responsibilities:
• Process management: Creating, scheduling, and terminating processes.
• Memory management: Allocating and deallocating memory for processes.
• Device management: Interfacing with hardware devices such as hard drives,
network interfaces, and printers.
• File system management: Organizing and controlling access to files on
storage devices.
• System calls: Providing an interface for applications to request services from
the operating system.
2. OS Structure –
2.1 Device Drivers:
• Device drivers are specialized programs that allow the operating
system to communicate with and control specific hardware devices.
• Responsibilities:
• Translating generic OS commands into instructions that hardware devices can
understand.
• Providing an abstraction layer that allows the rest of the operating system
and applications to interact with hardware without needing to understand
the hardware's low-level details.
2. OS Structure –
2.1 File System:
• The file system layer manages how data is organized and stored on
storage devices such as hard drives and solid-state drives.
• Responsibilities:
• Creating, deleting, and organizing files and directories.
• Controlling access to files through permissions.
• Handling file I/O operations, such as reading and writing data.
2. OS Structure –
2.1 User Interface:
• The user interface layer provides a means for users to interact with
the computer system.
• This can be through a command-line interface (CLI) or a graphical user
interface (GUI).
• Responsibilities:
• Accepting user commands or inputs.
• Displaying information to the user.
• Managing user interactions with the system.
2. OS Structure –
2.1 System Libraries:
• System libraries provide a collection of pre-written code and routines
that applications can use.
• These libraries abstract complex operations, making it easier for
programmers to develop software.
• Responsibilities:
• Offering reusable code for common tasks, such as mathematical calculations
or network communication.
• Allowing applications to access OS services without directly interacting with
the kernel.
2. OS Structure –
2.1 Application Programs:
• Application programs are software designed to perform specific tasks
or provide services to end-users.
• Responsibilities:
• Leveraging the services provided by the OS through system calls and libraries.
• Interacting with users and performing tasks according to the application's
purpose.
2. OS Structure –
2.2 Benefits of Layered OS Structure:
• Modularity:
• Each layer performs a specific set of functions, making the system modular
and easier to understand, develop, and maintain.
• Abstraction:
• Layers provide abstraction, allowing components to interact without knowing
the details of each other.
• Scalability:
• The modular structure allows for easy scalability and the addition of new
functionalities without disrupting existing layers.
2. OS Structure – Summary:
• The layered structure of operating systems facilitates efficient
resource management, enhances system stability, and simplifies the
development and maintenance of operating system software.
3. System Calls:
• System calls are essential interfaces between applications (user-level
programs) and the operating system.
• They allow programs to request services and resources from the
operating system kernel, which is the core part of the OS responsible
for managing system resources.
• System calls provide a standardized way for applications to interact
with the underlying hardware and perform privileged operations.
3. System Calls:
3.1 Key Characteristics of System 3. Device Management
Calls: 4. Information Maintenance
1. User-Space to Kernel-Space 5. Communication
Transition
3.3 System Call Execution Process:
2. Control Transfer
1. User Program Invocation
3. Parameter Passing
2. Trap/Interrupt
4. System Call Numbers
3. Kernel Mode Execution
3.2 Common Categories of System
Calls: 4. Parameter Validation and
Execution
1. Process Control
5. Result Return
2. File Management
3.4 Examples of System Calls
3. System Calls –
3.1 Key Characteristics of System Calls:
1.User-Space to Kernel-Space Transition:
• When a user-level program needs to perform a privileged operation (e.g., file I/O, process creation), it cannot
directly execute the operation itself due to security and protection mechanisms. Instead, it makes a system
call.
• The transition from user space to kernel space occurs, and the operating system takes control to execute the
requested operation on behalf of the application.
2.Control Transfer:
• A system call involves a transfer of control from the user program to the operating system. This transition is
usually triggered by a specific instruction, often called a "trap" or "software interrupt," that signals the CPU to
switch from user mode to kernel mode.
3.Parameter Passing:
• System calls often require parameters to specify details of the requested operation. These parameters are
typically passed in registers or a predefined memory location, depending on the architecture.
4.System Call Numbers:
• Each system call is identified by a unique number or code. When a user program invokes a system call, it
specifies the desired service by providing the corresponding system call number.
3. System Calls –
3.2 Common Categories of System Calls:
1.Process Control: 3. Device Management:
1. fork(): Create a new process. 1. ioctl(): Control device parameters.
2. exit(): Terminate the current process. 2. read() and write(): Perform I/O
3. wait(): Wait for a child process to operations on devices.
terminate. 4.Information Maintenance:
4. exec(): Replace the current process 1. getpid(): Get process ID.
image with a new one.
2. getuid(): Get user ID.
2.File Management: 3. time(): Get current time.
1. open(): Open a file.
2. read(): Read data from a file. 5.Communication:
3. write(): Write data to a file. 1. pipe(): Create a pipe for inter-process
communication.
4. close(): Close a file. 2. msgsnd() and msgrcv(): Send and
receive messages between
processes.
3. System Calls –
3.3 System Call Execution Process:
1.User Program Invocation:
• The application, running in user mode, makes a function call that corresponds to a specific system
call.
2.Trap/Interrupt:
• The system call instruction (e.g., INT 0x80 on x86 architectures) triggers a trap or interrupt, causing
a transition to kernel mode.
3.Kernel Mode Execution:
• The CPU transfers control to the operating system kernel, and the system call handler is invoked.
4.Parameter Validation and Execution:
• The kernel validates the parameters provided by the user program, ensuring they are valid and
authorized.
• The requested operation is then performed by the kernel.
5.Result Return:
• Upon completion of the system call, the result is returned to the user program, and control is
transferred back to user mode.
3. System Calls –
3.4 Examples of System Calls:
• open(path, flags)
• Opens a file identified by the given path and with specified flags (read, write, etc.).
• read(fd, buffer, count)
• Reads data from a file descriptor (fd) into a buffer.
• write(fd, buffer, count)
• Writes data from a buffer to a file descriptor.
• fork()
• Creates a new process, duplicating the calling process.
• exec(path, args)
• Replaces the current process image with a new one specified by the given executable
file path and arguments.
3. System Calls – Summary:
• Understanding system calls is crucial for both application developers
and system programmers, as it enables them to interact with the
underlying operating system and utilize its services efficiently.
• The abstraction provided by system calls allows applications to remain
independent of the underlying hardware and OS implementation.
4. Real-Time Operating Systems (RTOS):
• Real-Time Operating Systems (RTOS) are specialized operating
systems designed to meet the stringent timing requirements of real-
time applications.
• These applications include embedded systems, control systems,
robotics, aerospace, and other scenarios where timely and
predictable execution of tasks is crucial.
• RTOS provides deterministic behavior, ensuring that tasks are
executed within specified time constraints.
4. Tasks in RTOS:
• In an RTOS, tasks are the fundamental units of work or executable
entities.
• Tasks represent specific functions or processes that need to be
performed within the system.
• These tasks can be periodic, sporadic, or aperiodic, depending on the
real-time requirements of the application.
• Each task is assigned a priority, and the scheduler within the RTOS
determines the order in which tasks are executed based on their
priorities.
4. RTOS Task and Task State:
4.1 Characteristics of Tasks in RTOS: 4.3 Task State Transitions:
• Priority 4.4 RTOS Scheduler:
• Execution Time Constraints 4.5 RTOS Examples:
• Periodicity • FreeRTOS
• Periodicity • VxWorks
4.2 Task States in RTOS: • QNX
• Ready
• Running
• Blocked
• Suspended
4. RTOS Task and Task State –
4.1 Characteristics of Tasks in RTOS:
1.Priority:
1. Each task in an RTOS is assigned a priority level. The priority determines the order in which tasks are
scheduled for execution.
2. Higher-priority tasks are given preference and may preempt lower-priority tasks.
2.Execution Time Constraints:
1. Tasks in an RTOS have associated timing constraints, including deadlines and maximum allowable execution
times.
2. Meeting these constraints is crucial for ensuring the proper functioning of real-time applications.
3.Periodicity:
1. Some tasks in an RTOS may have fixed or variable periods between consecutive activations.
2. Periodic tasks are repeated at regular intervals, contributing to the predictability of the system.
4.Scheduling:
1. RTOS employs scheduling algorithms to determine the order in which tasks are executed based on their
priorities and timing constraints.
2. Common scheduling algorithms include Rate Monotonic Scheduling (RMS) and Earliest Deadline First (EDF).
4. RTOS Task and Task State –
4.2 Task States in RTOS:
(Indicating their current execution status)
1.Ready:
1. The task is ready to run but is waiting for the CPU to be assigned to it by the scheduler.
2. Tasks in the ready state are often waiting in a ready queue.
2.Running:
1. The task is currently being executed by the CPU.
2. Only one task can be in the running state at a given time.
3.Blocked:
1. The task is waiting for a specific event or resource and cannot proceed until that condition is
satisfied.
2. Tasks in the blocked state are often waiting in a blocked queue.
4.Suspended:
1. The task is temporarily halted, usually by explicit user or system command.
2. It can be resumed later to continue its execution.
4. RTOS Task and Task State –
4.3 Task State Transitions:
• The tasks in an RTOS transition between these states based on events, system
calls, or external stimuli.
• The scheduler is responsible for managing these transitions, ensuring that tasks
meet their deadlines and timing constraints.
2) OS Structure:
1. Explain the concept of layering in the structure of operating systems.
2. Identify and describe the purpose of the kernel in an operating system.
3. What is the role of device drivers in OS structure?
4. Name a common layer in the OS structure that interfaces with hardware.
2 Mark Question
3) System Calls:
1. What is the purpose of system calls in an operating system?
2. Give examples of services that can be requested through system calls.
3. How do system calls facilitate communication between applications and
the OS?
4. Why is memory allocation considered a system call?
6) Process Synchronization:
1. Why is process synchronization crucial in a multitasking environment?
2. What is the purpose of a critical section in process synchronization?
3. How does process synchronization contribute to preventing data corruption?
4. Name a synchronization primitive used in process synchronization.
2 Mark Question
7) Inter Process Communication (IPC):
1. Why is IPC important in multitasking environments?
2. Provide examples of IPC mechanisms.
3. How do message queues facilitate communication between processes?
4. What is the role of shared memory in IPC?
8) Critical Section:
1. Define a critical section in the context of code execution.
2. Why is it essential to control access to shared resources within a critical
section?
3. What problem does a critical section aim to prevent?
4. Name a synchronization mechanism used to manage critical sections.
2 Mark Question
9) Semaphores:
1. What is the purpose of using semaphores in operating systems?
2. Differentiate between binary semaphores and counting semaphores.
3. How does a semaphore achieve mutual exclusion?
4. Provide an example scenario where semaphores can be applied.
2) OS Structure:
1.Describe the layered structure of operating systems. Provide a comprehensive
overview of common layers, including their functions and interactions. Why is
layering considered a beneficial design approach in OS architecture?
2.Focus on the kernel as a core component of an operating system. Explain its
functionality and significance in managing the overall system. Discuss how device
drivers and the user interface contribute to the layered structure and user
interaction.
10 Mark Question
3) System Calls:
1.Explore the concept of system calls in operating systems. How do system calls serve as
interfaces for applications to request various services, including file operations, process
control, and memory allocation? Provide specific examples to illustrate their usage.
2.Discuss the mechanisms involved in handling system calls. How does the operating
system manage the transition from user mode to kernel mode during a system call, and
why is this transition necessary for security and stability?
6) Process Synchronization:
1.Explain in detail the concept of process synchronization in operating systems. Why is it
crucial for multiple tasks or processes to coordinate and share resources without
conflicts? Illustrate with examples how process synchronization prevents data corruption
and ensures proper operation.
2.Discuss various synchronization mechanisms used for process synchronization, such as
semaphores and mutex locks. Provide examples of situations where these mechanisms
are particularly useful and explain their role in maintaining system integrity.
10 Mark Question
7) Inter Process Communication (IPC):
1. Provide a comprehensive overview of Inter Process Communication (IPC) mechanisms. How do
message queues, mailboxes, pipes, and shared memory facilitate communication between
different tasks or processes? Discuss the advantages and limitations of each mechanism.
2. Explore the role of IPC in building collaborative and communicative systems. How does IPC
contribute to the efficient exchange of information and coordination between independent
processes? Provide real-world examples to illustrate the practical applications of IPC.
8) Critical Section:
1. Define and elaborate on the concept of a critical section in the context of code execution. Why is
it necessary to control access to shared resources within a critical section, and how does this
control prevent data corruption? Provide examples to illustrate the importance of critical sections
in concurrent programming.
2. Discuss different strategies for implementing critical sections, such as the use of mutex locks or
semaphores. What factors influence the choice of a particular strategy, and how does the
implementation of critical sections impact system performance?
10 Mark Question
9) Semaphores:
1.Explain the purpose of semaphores in operating systems. How do semaphores serve as
synchronization objects to control access to shared resources? Provide detailed examples
to illustrate how semaphores can be used to implement mutual exclusion and
coordination.
2.Compare and contrast binary semaphores and counting semaphores. How do these
types of semaphores differ in their applications and functionalities? Provide scenarios
where each type of semaphore is preferred.