14
STRUCTURE OPERATING SYSTEMS

STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

Embed Size (px)

DESCRIPTION

II. MEMORY MANAGEMENT RAM Array of words or bytes, each with its own address Loosely speaking, the only storage device the CPU can address directly (forgetting about cache) Many programs are in memory at the same time O/S Tasks Keep track of which pieces of memory are being used and by whom Decide which processes are to be loaded into memory Allocate/deallocate memory to processes

Citation preview

Page 1: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

STRUCTURE

OPERATING SYSTEMS

Page 2: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

I. PROCESS MANAGEMENT

• Process• a program in execution

• More than one process can be associated with a single program• Each is a separate execution sequence• All processes can potentially execute concurrently

• O/S Tasks• Creation/deletion of processes• Suspension and resumption of processes• Process synchronization• Interprocess communication• Deadlock detection

Page 3: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

II. MEMORY MANAGEMENT

• RAM• Array of words or bytes, each with its own address• Loosely speaking, the only storage device the CPU

can address directly (forgetting about cache)• Many programs are in memory at the same time

• O/S Tasks• Keep track of which pieces of memory are being

used and by whom• Decide which processes are to be loaded into

memory• Allocate/deallocate memory to processes

Page 4: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

III. FILE SYSTEM MANAGEMENT (1)

• Provides a uniform logical view of information storage• O/S Tasks• Creation/Deletion of files• Creation/Deletion of directories• Map files onto secondary storage• Backup files onto stable media

Page 5: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

III. FILE SYSTEM MANAGEMENT (2)

A file system for a university department.Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Page 6: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

III. FILE SYSTEM MANAGEMENT (3)

To be accessible, files must be mounted(a) before mount. (b) after mount

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Page 7: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

IV. PROTECTION

• Ensure that these can only be manipulated by processes with proper authority• Files• Memory• CPU

Page 8: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

V. I/O DEVICE MANAGEMENT (1)

A controller is hardware: The electronic component of a device. It has a standard interface (SATA, SCSI, USB, etc.). The controller translates input from software into something a device understands. Controllers can have memory and a processor. NICs and graphic cards are controllers.A Device drivers is software: provides an interface between the controller and the OS.

Page 9: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

V. I/O DEVICE MANAGEMENT (2)SUBTLE PROBLEMS

• Problem 1: Getting device driver into kernel• At boot time, OS detects controllers, finds the drivers it

needs and loads them• OS detects controllers and loads drivers on the fly—thumb

drives• Problem 2: OS issues i/o request• Busy/Wait• driver starts i/o and sits in tight loop polling device• i/o completes and driver alerts OS• Problem: wastes CPU cycles

• Interrupt • driver starts the device. Is interrupted when i/o completes• Problem: the interrupt handler is interrupted by another

device• Solution: When processing an interrupt, disable interrupts.

The devices continue to assert interrupt signals, but the CPU does not respond until interrupts are enabled.

Page 10: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

VI. COMMAND INTERPRETER

• Programmer interface to the o/s• Shell• Logging on creates a process on your behalf• $ indicates waiting for input• Issue a command (e.g., cp), shell starts a child

process called a system call

Page 11: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

VII. SYSTEM CALLS (1)

• Provides an interface between a running program and the o/s• To be distinguished from the shell. System calls

occur within a program• Every subsystem of the o/s has its own set of

system calls

Page 12: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

VII. SYSTEM CALLS (2)FILE MANAGEMENT EXAMPLE

#include <stdio.h> #include <fcntl.h> #include <sys/stat.h> int main(int argc, char* argv[]) {

int inFile, outFile; int len; char ch; if (argc != 3) {

printf("Usage: copy <f1> <f2>\n"); exit(1);

} inFile = open(argv[1], O_RDONLY); outFile = open(argv[2], O_WRONLY | O_CREAT, S_IRWXU);while ((len = read(inFile, &ch, 1)) > 0) {

write(outFile, &ch, 1);} close(inFile); close(outFile); return 0;

}

Page 13: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

VII. SYSTEM CALL (3)PROCESS MANAGEMENT

• Processes are created through other processes• As early as 1963, researchers postulated 3

process creation functions• fork() – create a process• join() – merge two processes• quit() – terminate a process

Page 14: STRUCTURE OPERATING SYSTEMS. I. PROCESS MANAGEMENT Process a program in execution More than one process can be associated with a single program Each is

THERE IS MUCH,MUCH MORE