150 likes | 252 Vues
Learn about the resource manager, hardware resources, and objectives of operating systems. Understand the evolution, convenience, and efficiency of OS. Explore process management and memory abstraction.
E N D
Operating Systems 2 - overview PIETER HARTEL
Operating System • Resource manager • Hardware resources • Resources provided by the OS itself (which?) • Objectives • Convenience (why?) • Efficiency (why?) • Evolvability (why?) • Abstraction is the key to managing the complexity
History • Batch • Time sharing • Real-time • Multi-processor • Distributed systems • Multi-core (why?) Electrologica X8 console, 1965
Concepts and abstractions Concept • Processes & Threads • Memory management • Protection and security • Scheduling and resource management Abstraction of • Processor • Physical memory & disks • Dedicated computer • Dedicated computer
Linux example of the Unix API #include <stdio.h> int main(intargc, char *argv[]) { inti; for(i=0;i<argc-1; i++) { printf("%s ", argv[i]); } printf("%s (%d)\n", argv[argc-1], argc); return 0; } • Output? • gccEcho.c • ./a.out Hello world • strace ./a.out Hello World
Resource sharing (why?) • Deadlock (why?) • Prevention • Detection • Recovery • Avoidance
Process management • Scheduling • Timer • Threads (why?) Which process is running?
Address space management • Output? • gccAddressSpace.c • ./a.out low extern char etext, edata, end; int a = 0xaaaa, b; intmain(intargc, char * argv[]) { int c = 0xcccc; int *d_ptr = (int*) malloc(sizeof(int)); int *e_ptr = (int*) alloca(sizeof(int)); b = 0xbbbb; *d_ptr = 0xdddd; *e_ptr = 0xeeee; printf("%p:a=%0x\n", &a, a); … } heap stack high
Memory management • Paging (why?) • MMU! • Swapping (why?)
Protection and Security • Processes vs the OS (how?) • Processes vs other Processes (how?) • Privileged processes (why?) • Access control matrix
#include <stdio.h> #include <unistd.h> #define N 41 int main(intargc, char * argv[]) { if(argc >= 3) { FILE *from = fopen(argv[1], "r"); FILE *to = fopen(argv[2], "w"); char buf[N]; while (fgets(buf,N,from) != NULL) { fputs(buf,to); fputc('\n',to); } fclose(from); fclose(to); return 0; } else { printf("usage %s from to\n", argv[0]); return 1; } } I/O management • Output? • gcc Wrap.c • strace ./a.out Wrap.c junk • Find the system calls for: • fgets() • fputs()
Virtual Machine management • Examples?
Summary • Operating systems are large, hence abstraction to manage complexity: • Processes and threads • Memory • Files and peripherals • User accounts • Management issues • Fairness • Sharing • Protection