Download OS Basics

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Acorn MOS wikipedia , lookup

RSTS/E wikipedia , lookup

Copland (operating system) wikipedia , lookup

CP/M wikipedia , lookup

Spring (operating system) wikipedia , lookup

VS/9 wikipedia , lookup

Burroughs MCP wikipedia , lookup

DNIX wikipedia , lookup

Distributed operating system wikipedia , lookup

Thread (computing) wikipedia , lookup

Paging wikipedia , lookup

Kernel (operating system) wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
Real Time Operating
System
Topics
1. Operating System Services
a. GOAL,
b. MODES AND
c. STRUCTURE
2. Process Management (Kernel service)
3. Memory Management (Kernel service)
INTRODUCTION
 An operating system (OS) is a software
program that manages the hardware
and software resources of a computer.
 It is just a intermediate of Hardware
and Software.
 The OS performs basic tasks, such as
 Controlling and allocating memory,
 Prioritizing the processing of
instructions,
 Controlling input and output devices,
 Facilitating
networking,
and
managing files.
GOAL OF OPERATING SYSTEM SERVICES
1. Providing easy sharing of resources as per
schedule and allocation.
 Resources mean processor(s), memory, I/Os devices,
virtual devices(pipes & Sockets), System timer, Keyboard,
displays printer and other such resources which processes
(task or threads) request from the OS.
 No processing task or thread uses any resources until it
has been allocated by the OS at a given time or instance.
2. Providing easy implementation of the
application-program with in the given systemhardware.
 An Application programmer for a system can use the OS
functions that are provided in given OS.
3. Optimally scheduling the processes on one (or
more CPUs if available) by providing an
appropriate context switching mechanism.
 A context switch (also sometimes referred to as a process
switch or a task switch) is the switching of the CPU (central
processing unit) from one process or thread to another.
4. Maximizing the system performance to let
different processes (or tasks or threads) share
the resources most efficiently with protection
and without any security breach.
 Security breach are tasks obtaining illegal access to other
tasks-data directly without system call.
5. Providing management & Organization
functions for the processes (tasks or threads),
memory, file, physical and virtual devices and
I/Os and for other functions for which it is
designed.
6. Providing easy interfacing and management
functions for the network protocols and
network
7. Providing portability of the application on
different hardware configurations.
8. Providing a common set of interfaces that
integrates various devices and applications
through standard and open systems
MODES OF OPERATING SYSTEM
1. User Mode
2. Supervisor Mode
User and Supervisory mode structure
 Processor in the system running in two modes.
 The processor switches between the two modes depending
on what type of code is running on the processor.
 Applications run in user mode, and core operating system
components run in Supervisor or kernel mode.
 Many drivers run in kernel mode, but some drivers run in
user mode.
User Mode
 In User mode, the executing code has no ability to directly access
hardware or reference memory. Code running in user mode must
delegate to system APIs to access hardware or memory.
 Due to the protection and isolation, crashes in user mode are always
recoverable. Most of the code running on your computer will execute in
user mode.
 Use of OS functions in user mode─ either by sending a message to the
waiting process associated in the OS kernel space or by system call (calling
an OS function).
 User function call, which is not a system call, is not permitted to read and
write into the protected memory allotted to the OS functions, data, stack
and heap
 That protected memory space is also called kernel space. Hence execution
of user functions calls is slower than the execution of the OS functions (on
system call) due to need to spend time in first checking the access
permission to the protected space.
Supervisory Mode
 It is also known as Kernel Mode.
 In Kernel mode, the executing code has complete and unrestricted access
to the underlying hardware. It can execute any CPU instruction and
reference any memory address.
 Kernel mode is generally reserved for the lowest-level, most trusted
functions of the operating system. Crashes in kernel mode are
catastrophic; they will halt the entire PC.
 OS runs in protected mode the privileged functions and instructions in
protected mode that are the privileged ones and the OS (more specifically,
the kernel) is only one permitted to access the hardware resources and
protected area memory.
 Kernel space functions and processes execute faster than the user space
functions and processes.
Figure1: Communication between user-mode and kernel-mode components.
Example:- Improving system performance by
running application program threads in supervisory
(kernel) mode.
e.g
RTOS Windows CE (Windows Embedded Compact) and
several RTOSes
 Run all the threads run in the supervisory mode
(kernel mode). Therefore, the threads executes fast.
 Improves the system performance.
 If the threads are to execute in user mode, as in Unix
or in non-real time OS, then the execution slows
down due to time spent in checks on the code access
to the protected kernel space
What is Kernel ??and its
Services in the OS??
Kernel and its Services in the OS
What is kernel first?????
 heart of the operating system
 A kernel connects the application software to the hardware of a
computer
 The kernel is a program that constitutes the central core of a
computer operating system. It has complete control over
everything that occurs in the system.
 It provides the very basic facilities for the management such as
processor
management,
I/O
management,
memory
management, and process management of efficient execution of
the system.
 A kernel can be contrasted with a shell, the outermost part of
an operating system that interacts with user commands.
 Kernel and shell are terms used more frequently
in Unix operating systems than in IBM mainframe or Microsoft
Windows systems.
Figure 2:
We can visualize a whole Operating
System like an Atom structure.
Kernel basic facilities
The kernel's primary function is to manage the computer's resources and allow
other programs to run and use these resources. Typically, the resources consist of:
 The Central Processing Unit. This is the most central part of a computer system,
responsible for running or executing programs. The kernel takes responsibility for
deciding at any time which of the many running programs should be allocated to
the processor or processors (each of which can usually run only one program at a
time)
 The computer's memory. Memory is used to store both program instructions and
data. Typically, both need to be present in memory in order for a program to
execute. Often multiple programs will want access to memory, frequently
demanding more memory than the computer has available. The kernel is
responsible for deciding which memory each process can use, and determining
what to do when not enough is available.
 Any Input /Output (I/O) devices present in the computer, such as keyboard,
mouse, disk drives, USB devices, printers, displays, network adapters, etc. The
kernel allocates requests from applications to perform I/O to an appropriate
device (or subsection of a device, in the case of files on a disk or windows on a
display) and provides convenient methods for using the device (typically abstracted
to the point where the application does not need to know implementation details
of the device).
 Kernels also usually provide methods for synchronization and communication
between processes called inter-process communication (IPC).
Kernel Services in the OS
1. Process Management.
2. Memory Management.
3. I/O Device Management.
4. Processor Management.
Process Management Kernel Services in an OS.
 Creation to deletion of Processes
 Process structure maintenance
 Processing resource requests
 Scheduling Processes
 Inter
process
Communication
(IPC)
(communication between Tasks, ISRs, OS
functions)
Process Creation
Step 1: At the reset of the processor. in a computer
system, an OS is initialized first─ enabling the use of
the OS functions, which includes the function to
create the processes.
Step 2: Using OS process creation function, a
process, which can be called initial process, is
created.
Step 3: OS started and that calls the initial process
to run.
Step 4: When the initial process runs, it creates
subsequent processes.
Processes can be created hierarchically.
OS schedules the threads and provide for context
switching between the threads (or tasks).
Creation of a process
 Means defining the resources for the process and address
spaces (memory blocks) for the created process, its stack,
its data and placing the process initial information at a
PCB(Process Control Block), or TCB(Task Control Block)
What is PCB or TCB?????
 Process Control Block (PCB, Process descriptor or also
called Task Controlling Block) is a data structure in
the operating system kernel containing the information
needed to manage a particular process or task.
Information provided by PCB
The PCB contains important information about the specific process
including:
1. The current state of the process i.e., whether it is ready,
running, waiting, or whatever.
2. Unique identification of the process in order to track "which is
which" information.
3. A pointer to parent process.
4. Similarly, a pointer to child process (if it exists).
5. The priority of process (a part of CPU scheduling information).
6. Pointers to locate memory of processes.
7. A register save area.
8. The processor it is running on.
Example of Process Creation
Suppose I have to create a OS function of Display for a mobile phone
device.
An OS function first creates the Display_process. The display process then
creates the following threads:
1. Display_Time_DateThread
2. Display_BatteryThread
3. Display_SignalThread
4. Display_ProfileThread
5. Display_MessageThread
6. Display_Call StatusThread
7. Display_MenuThread
Process Manager Functions
 Implements CPU sharing (called scheduling)
 Must allocate resources to processes in conformance with
certain policies
 Implements process synchronization and inter-process
communication
 Implements deadlock strategies and
protection
mechanisms
Memory Management
Memory Management Kernel Services in an
OS.
 Allocation and de-allocation between Tasks, ISRs,
OS functions.
 Shared Memory Management
 It takes care of Memory Protection also.
Memory allocation
 When a process is created, the memory manager
allocates the memory addresses (blocks) to it by
mapping the process address space.
 Threads of a process share the memory space of
the process
Memory Management after Initial
Allocation
 Memory manager of the OS─ secure, robust and well
protected.
 No memory leaks and stack overflows.
 Memory leaks means attempts to write in the memory
block not allocated to a process or data structure.
 Stack overflow means that the stack exceeding the
allocated memory block(s)
Memory managing Strategy for a system
Topics
Basic OS Functions
 Process Management,(done)
 Memory Management(done)
 Device Management(SS)
 I/O Device Management(SS)