Top Banner
Operating System Prepared By: Junicel Estomo
36
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Os

Operating System

Prepared By: Junicel Estomo

Page 2: Os

What is an Operating System?

● The 1960’s definition of an operating system is “the software that controls the hardware”.

Page 3: Os

Objectives of Operating Systems

● To hide details of hardware by creating abstraction● To allocate resources to processes (Manage

resources)● Provide a pleasant and effective user interface

Page 4: Os

One can view Operating Systems from two points of views:

Resource manager and Extended machines

Page 5: Os

History of Operating Systems

● The 1940's - First Generations● The 1950's - Second Generation● The 1960's - Third Generation● Fourth Generation

Page 6: Os

System Components

● Process Management– The five major activities of an operating system in

regard to process management are:● Creation and deletion of user and system processes.● Suspension and resumption of processes.● A mechanism for process synchronization.● A mechanism for process communication.● A mechanism for deadlock handling.

Page 7: Os

Main-Memory Management

● The major activities of an operating in regard to memory-management are:– Keep track of which part of memory are currently

being used and by whom.– Decide which process are loaded into memory when

memory space becomes available.– Allocate and deallocate memory space as needed.

Page 8: Os

File ManagementA file systems normally organized into directories to ease their use. These directories may contain files and other directions.

● The five main major activities of an operating system in regard to file management are:1.The creation and deletion of files.2.The creation and deletion of directions.3.The support of primitives for manipulating files and

directions.4.The mapping of files onto secondary storage.5.The back up of files on stable storage media.

Page 9: Os

I/O System Management

● I/O subsystem hides the peculiarities of specific hardware devices from the user. Only the device driver knows the peculiarities of the specific device to whom it is assigned.

Page 10: Os

Secondary-Storage Management ● Generally speaking, systems have several levels of

storage, including primary storage, secondary storage and cache storage.

● Instructions and data must be placed in primary storage or cache to be referenced by a running program.

● The three major activities of an operating system in regard to secondary storage management are:1.Managing the free space available on the secondary-

storage device.2.Allocation of storage space when new files have to be

written.3.Scheduling the requests for memory access

Page 11: Os

Networking

● The processors communicate with one another through communication lines called network.

● The communication-network design must consider routing and connection strategies, and the problems of contention and security.

Page 12: Os

Protection System

● If a computer systems has multiple users and allows the concurrent execution of multiple processes, then the various processes must be protected from one another's activities.

● Protection refers to mechanism for controlling the access of programs, processes, or users to the resources defined by a computer systems.

Page 13: Os

Command Interpreter System

● A command interpreter is an interface of the operating system with the user.– There are two main advantages to separating the

command interpreter from the kernel.1.If we want to change the way the command interpreter looks2.If the command interpreter is a part of the kernel

Page 14: Os

Chapter 4

Process

Page 15: Os

● The term "process" was first used by the designers of the MULTICS in 1960's. Since then, the term process, used somewhat interchangeably with 'task' or 'job'. The process has been given many definitions for instance– A program in Execution.– An asynchronous activity.– The 'animated sprit' of a procedure in execution.– The entity to which processors are assigned.– The 'dispatchable' unit.

Page 16: Os

Process, on the other hand, includes:

● Current value of Program Counter (PC)● Contents of the processors registers● Value of the variables● The process stack (SP) which typically contains

temporary data such as subroutine parameter, return address, and temporary variables.

● A data section that contains global variables.

Page 17: Os

A process is the unit of work in a system.

Page 18: Os

Process State

● The process state consists of at least following:– * Code for the program.– * Program's static data.– * Program's dynamic data.– * Program's procedure call stack.– * Contents of general purpose registers.– * Contents of program counter (PC)– * Contents of program status word (PSW).– * Operating Systems resource in use.

Page 19: Os

A process goes through a series of discrete process states.

● New State● Running State● Blocked (or waiting) State● Ready State● Terminated state

Page 20: Os

Process Operations

● Process Creation– System initialization.– Execution of a process Creation System calls by a

running process.– A user request to create a new process.– Initialization of a batch job.

Page 21: Os

● A process may create a new process by some create process such as 'fork'.

● It choose to does so, creating process is called parent process and the created one is called the child processes

● This creation of process (processes) yields a hierarchical structure of processes like one in the figure.

Page 22: Os

Following are some reasons for creation of a process

● User logs on.● User starts a program.● Operating systems creates process to provide

service, e.g., to manage printer.● Some program starts another process, e.g.,

Netscape calls xv to display a picture.

Page 23: Os

Process Termination

● The new process terminates the existing process, usually due to following reasons:– Normal Exist– Fatal Error– Killed by another Process

Page 24: Os

Process States

● A process goes through a series of discrete process states.

● New State● Terminated State● Blocked (waiting) State● Running State● Ready State

Page 25: Os

Process State Transitions

● Following are six(6) possible transitions among above mentioned five (5) states– Transition 1 occurs when process discovers that it

cannot continue. If running process initiates an I/O operation before its allotted time expires, the running process voluntarily relinquishes the CPU.

– Transition 2 occurs when the scheduler decides that the running process has run long enough and it is time to let another process have CPU time.

– Transition 3 occurs when all other processes have had their share and it is time for the first process to run again

Page 26: Os

cont...

– Transition 4 occurs when the external event for which a process was waiting (such as arrival of input) happens.

– Transition 5 occurs when the process is created.– Transition 6 occurs when the process has finished

execution.

Page 27: Os

Process Control Block

● The PCB contains important information about the specific process including:– The current state of the process i.e., whether it is ready,

running, waiting, or whatever.– Unique identification of the process in order to track

"which is which" information.– A pointer to parent process.– Similarly, a pointer to child process (if it exists).– The priority of process (a part of CPU scheduling

information).– Pointers to locate memory of processes.– A register save area.– The processor it is running on

Page 28: Os

Threads● Threads● Processes Vs Threads● Why Threads?● User-Level Threads● Kernel-Level Threads● Advantages of Threads over Multiple Processes● Disadvantages of Threads over Multiprocesses● Application that Benefits from Threads● Application that cannot benefit from Threads● Resources used in Thread creation and Process

Creation● Context Switch● Major Steps of Context Switching● Action of Kernel to Context switch among threads● Action of kernel to Context switch among processes

Page 29: Os

Threads

● A thread is a single sequence stream within in a process.

● a thread of execution is the smallest unit of processing that can be scheduled by an operating system.

● Because threads have some of the properties of processes, they are sometimes called lightweight processes, LWP is a specific type of kernel thread that shares the same state and information.

Page 30: Os

Processes Vs Threads

Similarities● Like processes threads

share CPU and only one thread active (running) at a time.

● Like processes, threads within a processes, threads within a processes execute sequentially.

● Like processes, thread can create children.

● And like process, if one thread is blocked, another thread can run.

Differences● Unlike processes, threads

are not independent of one another.

● Unlike processes, all threads can access every address in the task .

● Unlike processes, thread are design to assist one other. Note that processes might or might not assist one another because processes may originate from different users.

Page 31: Os

Why Threads?

Following are some reasons why we use threads in designing operating systems.1.A process with multiple threads make a great server for

example printer server.2.Because threads can share common data, they do not

need to use interprocess communication.3.Because of the very nature, threads can take advantage

of multiprocessors

Page 32: Os

Cont...

Threads are cheap in the sense that

1.They only need a stack and storage for registers therefore, threads are cheap to create.

2.Threads use very little resources of an operating system in which they are working. That is, threads do not need new address space, global data, program code or operating system resources.

3.Context switching are fast when working with threads. The reason is that we only have to save and/or restore PC, SP and registers.

Page 33: Os

User-Level Threads

User-level threads implement in user-level libraries, rather than via systems calls, so thread switching

does not need to call operating system and to cause interrupt to the kernel. In fact, the kernel

knows nothing about user-level threads and manages them as if they were single-threaded

processes.

Page 34: Os

Advantages:

● User-level threads does not require modification to operating systems.

● Simple Representation:● Simple Management:● Fast and Efficient

Page 35: Os

Disadvantages:● There is a lack of coordination between threads

and operating system kernel. Therefore, process as whole gets one time slice irrespect of whether process has one thread or 1000 threads within. It is up to each thread to relinquish control to other threads.

● User-level threads requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will blocked in the kernel, even if there are runable threads left in the processes. For example, if one thread causes a page fault, the process blocks.

Page 36: Os