Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CHAPTER 2: OPERATING SYSTEM STRUCTURES OS SERVICES: THE BIG VIEW (1) • User interface - Almost all operating systems have a user interface: Command-Line, Graphics User Interface (GUI), Batch • Program execution – load, run, executed, end execution • I/O operations - Deal with I/O devices • File-system manipulation - Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. • Communications – Processes frequently exchange information through message passing or shared memory OS SERVICES: THE BIG VIEW (2) • Error detection – OS needs to be constantly aware of possible errors: CPU, memory, I/O devices and be able to take action • Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them: CPU, RAM, files, I/O devices • Accounting - To keep track of which users use how much and what kinds of computer resources • Protection and security – • Protection - ensure that all access to system resources is controlled • Security – protect system from outside users A VIEW OF OPERATING SYSTEM SERVICES SYSTEM CALLS • Programming interface to the services provided by the OS • Typically written in a high-level language (C or C++) • Mostly accessed by programs via a high-level Application Programming Interface (API) rather than direct system call use • Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) EXAMPLE OF SYSTEM CALLS • System call sequence to copy the contents of one file to another file EXAMPLE OF STANDARD API SYSTEM CALL IMPLEMENTATION • The system call interface invokes the intended system call in OS kernel and returns status of the system call and any return values • The caller need know nothing about how the system call is implemented • Just needs to obey API and understand what OS will do as a result call • Most details of OS interface hidden from programmer by API API – SYSTEM CALL – OS RELATIONSHIP TYPES OF SYSTEM CALLS • Process control • create process, terminate process • end, abort • load, execute • get process attributes, set process attributes • wait for time • wait event, signal event • allocate and free memory • Dump memory if error • Debugger for determining bugs, single step execution • Locks for managing access to shared data between processes TYPES OF SYSTEM CALLS • File management • create file, delete file • open, close file • read, write, reposition • get and set file attributes • Device management • request device, release device • read, write, reposition • get device attributes, set device attributes • logically attach or detach devices TYPES OF SYSTEM CALLS (CONT.) • Information maintenance • get time or date, set time or date • get system data, set system data • get and set process, file, or device attributes • Communications • create, delete communication connection • send, receive messages if message passing model to host name or process name • From client to server • Shared-memory model create and gain access to memory regions • transfer status information • attach and detach remote devices TYPES OF SYSTEM CALLS (CONT.) • Protection • Control access to resources • Get and set permissions • Allow and deny user access EXAMPLES OF WINDOWS AND UNIX SYSTEM CALLS SYSTEM CALL 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; } SINGLE-TASKING: MS-DOS • Single-tasking • Shell invoked when system booted • Simple method to run program • No process created • Single memory space • Loads program into memory, overwriting all but the kernel • Program exit -> shell reloaded At system startup running a program MULTITASKING: UNIX • Multitasking • User login -> invoke user’s choice of shell • Shell executes fork() system call to create process • Executes exec() to load program into process • Shell waits for process to terminate or continues with user commands • Process exits with: • code = 0 – no error • code > 0 – error code TRADITIONAL UNIX SYSTEM STRUCTURE SYSTEM BOOT • When power initialized, execution starts at a fixed memory location • Firmware ROM used to hold initial boot code • Operating system must be made available to hardware so hardware can start it • Small piece of code – bootstrap loader, stored in ROM or EEPROM locates the kernel, loads it into memory, and starts it • Sometimes two-step process where boot block at fixed location loaded by ROM code, which loads bootstrap loader from disk • Common bootstrap loader, GRUB, allows selection of kernel from multiple disks, versions, kernel options • Kernel loads and system is then running O/S MILESTONES (1) • IBSYS • Fifties • Resident monitor • IBM 1401/7094 • OS/360 • • • • Sixties IBM 360 Multiprogramming Frederick Brooks, The Mythical Man-Month • CTSS (Conversational Timesharing System) • Early sixties • MIT for IBM 7098 • Early version of time sharing 5/9/2017 20 O/S MILESTONES (2) • Multics • • • • Mid sixties MIT, Bell Labs, GE Many seminal o/s ideas, time-sharing in particular Idea of a computer utility • OS/370 • Time sharing • Virtual memory (but Manchester Atlas was first VM machine) 5/9/2017 21 O/S MILESTONES (3) • Unix • Ken Thompson worked on Multics • He and Dennis Ritchie create a strippeddown, one user version of Multics • Early seventies • DEC PDP-7 • Later ported to a PDP-11: led to the idea that an o/s does not have to be hardware specific • PDP-11 version written in C (Kernighan and 5/9/2017 Ritchie) 22 O/S MILESTONES (4) • MS-DOS • Early 80s • Built for IBM to exploit mass-marketed 8086 • Preceded by CP/M (Gary Kildall, consultant to Intel) • Minix • Mid 80s • Teaching version of Unix to run on intel processors 5/9/2017 23 O/S Milestones (4) • Linux • 90’s • Fully-featured o/s • Linus Thorvalds Hello everybody out there using minix - I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the filesystem (due to practical reasons) among other things). I've currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I'll get something practical within a few months, and I'd like to know what features most people would want. Any suggestions are welcome, but I won't promise I'll implement them :-) Linus ([email protected]) PS. Yes – it's free of any minix code, and it has a multi-threaded fs. It is NOT portable (uses 386 task switching etc), and it probably never will support anything other than AT-harddisks, as that's all I have :-(. 5/9/2017 24 O/S MILESTONES (5) • Windowing Systems • Doug Engelbart SRI, Xerox Parcmouse, windows etc. • Steve Jobs saw it during a visit Macintosh • Microsoft Windows in all of its incarnations 5/9/2017 25 OS MILESTONES (6) • Virtual Machines • Create the illusion of multiple operating systems running on the same physical hardware • IBM’s CP/CMS and VM/370 (early seventies) • VirtualBox, VMware (current) 5/9/2017 26 OS MILESTONES (7) • Mobile Computing • 1990s: Combine personal digital assistant (PDA) and mobile phone • Term “smartphone” coined in 1997 • Current Dominant OS • Linux-based Android from Google • iOS from Apple 5/9/2017 27