operating system concepts

Download Operating System Concepts

Post on 23-Oct-2014

281 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

Introduction To Operating System

Computer System

Hardware

Software

User

Input Units

CPU

Output Units

Secondary storage

Operating System

Application Programs

Compilers & Assemblers

Processor Memory

Control Unit

Magnetic TapesMagnetic Disks

Compact Disks

Programming Languages

RAM

Cache Memory

ROM

Floppy Disks

Hard Disks

High Level

Low Level

Q: Explain what is meant by Application Programs? Sol:User

Application ProgramsSoftware

Operating System

Hardware

Application programs

Are programs produced by programming companies to help computer users to perform useful tasks.

Q: Draw a block diagram showing the computer internal structure. Sol:

Instructions

Input Units

Instructions

Control Unit

Control Signals

Data

Memory (RAM) Output UnitsResults

ProcessorCache MemoryData

ALUStore ResultsOr Load date Results

Secondary Storage

ROM

CPU

Q: Define the following: RAM ROM Cache Memory Sol: RAM:

Random Access Memory Volatile (lose contents when power is off). Can be modified by the user.

ROM:

Read only Memory Non Volatile. Contains fixed programs used by the computer.

Cache Memory:

A memory inside the processor chip. Used to store frequently used data. Increases the processor speed.

ProcessorCache Memory

ALU

Q: Write short notes about: Secondary Storage Units Sol:

Definition: Secondary storage units are the units used to store data permanently.

Secondary Storage

Magnetic Disks

Magnetic Tapes

Compact Disks

Floppy Disks

Hard Disks

Magnetic Tapes: Used to store large volume of data in large computers like mainframes

for long time. Consists of plastic film coated by magnetic material (iron oxide).

Advantages: Compact (can store huge amount of data). Economical (low cost). No loss of data. Disadvantages: Sequential storage.

Magnetic Disks:

A surface of metal (in the case of hard disk) or plastic (in floppy disks) coated with magnetic material. It rotates with a high speed. Divided into tracks and sectors. Track Sector

Compact Disks:

CD/ROM (Compact Disk/Read Only Memory). A plastic surface coated by a reflective material. A laser beam is used to write on CD/ROM. Can store up to 600 Mega byte.

Q: Define OS, then what are the different OS goals? Sol: Operating System (OS): is the program running all the times on the computer to communicate all computer components (usually called Kernel). OS does not perform a useful task by itself, but it creates a suitable environment so that other programs can operate efficiently.

OS Goals: Convenient for the user. Efficient for the system components.

Q: What are the different types of OS? Sol:

Different Types of OS are:1. Batch System. 2. Multi-Programming System. 3. Multi-Tasking (Time Sharing) System. 4. Multi-Processor (Parallel) System. 5. Network Operating Systems. 6. Real Time Systems.

Batch System: Users send their jobs to the computer operator. Operator organize jobs into a set of batches (each contains similar jobs). Each batch is run separately as a set of jobs.

Batch 1

Next batch

OperatorBatch 2

CPUBatch 1 Job

Multi-Programming System: A number of processes are in memory inside the ready queue waiting for the CPU (there is one user). Windows OS using this concept.

Process 1Ready Queue Process 2 Process 3 Memory

Switching between processes

CPU

Multi-Tasking (Time sharing) System: Allow a number of users to share the CPU in the same time. This concepts is used in the mainframe computers.

User 1

Ready Queue for user 1

Process 1 Process 2 Process 3

User 2

Ready Queue for user 2

Process 1Process 2 Process 3

CPUSwitching between users processes

User 3

Ready Queue for user 3

Process 1 Process 2 Process 3

Memory

Multi-Processor System: Is a system with more than one processor to maximize the system speed.

CPU 1Ready QueueProcess 1 Process 2

User

CPU 2

Process 3

CPU 3 Memory

Network System: Systems that operate networks in order to achieve: Resource sharing. Computation speedup. Load balancing. Communication between hosts. Star

Bus

Ring

Real Time System: Systems that performs critical tasks.

Real Time Systems

Hard Real Time Systems

Soft Real Time Systems

Hard real time systems: critical tasks must be performed on time. Soft real time systems: critical tasks gets priority over other tasks.

Q: What are the different activates supported by modern OS? Sol:

Different OS functions are:1. Process Management. 2. Memory Management.

3. File Management.4. Storage Management. 5. I/O Management.

6. Protection Management.7. Networking Management.

Process Management

Q: Define the following: Process Resource Sol: Process :is a program in execution; it is an active entity in the memory while the program is the passive copy in the hard disk.

Process 1Program

MemoryProcess 2

Hard Disk

Resource: any things in the system that may be used by active processes. They may be hardware (printers, tape drives, memory), or software (files, databases).

Resource Types

Preemptive Resources

Non Preemptive Resources

A resource that stops the current process when a higher priority process comes.

A resource that can not stop the current process when a higher priority process comes.

Ex: Memory.

Ex: CD recorder,

Q: Explain why? Memory is a preemptive recourse. Sol:

Because It allows a low priority process to swapped out

form it to the disk when a higher priority process arrives and needs a larger amount of memory than the available. The low priority process can resume execution later (swapped in again).

Assume a system with 32 kb memory size.

5kb are used for OS, 10 kb for the low priority process. Hence, the available space is 17 kb. A higher priority process arrives and needs 20 kb.high priority process finishes executionOS (5 kb) OS (5 kb) Swap in the high priority process OS (5 kb)

Disk

Swap out the low priority process to disk

OS (5 kb) Low Priority process (10 kb) Available 17 Kb

Available 27 Kb

High Priority process (20 kb)

Available 27 Kb

Available 7 Kb

Swap in the low priority process again toresume execution

High Priority 20 Kb

Q: Explain why? CD recorder is nonpreemptive resource. Sol:

Because: If a process has begun to burn a CD-ROM, suddenly taking the CD recorder away from it and giving it to another process will result in a bad CD.

Q: What are the different steps to utilize a resource by a process? Sol:A process may utilize a resource in only the following sequence as shown below:

Request Use

Release

Q: Explain the main differences between a input (job) and ready queues?Sol: -input queue: stores the programs that will be opened soon (located at the disk) - ready queue: contains the active process that are ready to be executed (located in the memory).Ready Queue

Process need to be executed (programs)

Q: Explain what is meant by process states, and then draw the process state diagram. Sol: As process executes, it changes its state. The process state may be:

New: The process is being created. Ready: The process is waiting for the processor. Running: The process instructions are being executed. Waiting: The process is waiting for an event to happen (such as I/O completion).

Terminated: The process has finished execution.

The process state diagram is:

Dispatcher

Q: Explain why? Each process must have a process control block (PCB) in memory. Sol:

Because: Process control block (PCB) is the way used to represent the process in the operating system.

It contains information about the process such as: Process state (new, ready, ) Address of the next instruction to be executed in the process. Process priority. Process assigned memory. I/O information (such as I/O devices and opened files).

Q: Show graphically how OS uses the PCB to switch between active processes Sol:

When interrupt happened, OS saves the state of the current active process to its PCB so it can continue correctly when it resumes its execution again. To resume execution, OS reloads the process state from its PCB and continue execution.

Q: Give a suitable definition for the "Context Switch", and then explain why context switch is a pure overhead? Sol: Context switch is the time needed by OS to switch the processor from a process to another.

Context switch(Px Py) = TX + TY , where

TX : time needed to save the state of Px in PCBx TY : time needed to load the state of PY in PCBY Context switch is a pure overhead because the system

does no useful work while switching.

Q: what is meant by Schedulers?, then discuss different types of them? Sol: Long-term scheduler (or job scheduler) selects which processes should be brought into the ready queue from the job queue (determine the degree of multi-programming) Short-term scheduler (or CPU scheduler) selects which

process should be executed next and allocates CPU Medium-term scheduler: swap out the