Slides: OS Structure
Download
Report
Transcript Slides: OS Structure
OPERATING SYSTEMS
STRUCTURE
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
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
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
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.
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.
IV. PROTECTION
• Ensure that these can only be manipulated by
processes with proper authority
• Files
• Memory
• CPU
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.
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.
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
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
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;
}
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
THERE IS MUCH,MUCH MORE