1 / 38

Outline

Outline. Using the Operating Systems The abstract model of computing Resources Files Processes Threads System calls Review exercises Nutt 1.4 (p. 21) 1, 2, 6, 8, and 9. Review: System Overview. Review: What is an Operating System?.

Download Presentation

Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Outline • Using the Operating Systems • The abstract model of computing • Resources • Files • Processes • Threads • System calls • Review exercises • Nutt 1.4 (p. 21) 1, 2, 6, 8, and 9

  2. Review: System Overview COP4610

  3. Review: What is an Operating System? • An operating system is a system program that acts between the hardware and the user programs • It provides services to user programs • Through system calls / message passing • File system services • Memory services • I/O services • It hides hardware from user programs • When your program shows a message on the monitor, it does not need to know the details • When your program generates a new file, it does not need to where the free space is on your hard drive COP4610

  4. Review: Resource Sharing • Two types of sharing • Time multiplexing • time-sharing • schedule a serially-reusable resource among several users • Space multiplexing • space-sharing • divide a multiple-use resource up among several users COP4610

  5. Review: Time-multiplexing the Processor - Called concurrent execution or concurrency COP4610

  6. Batch Processing Systems • Hire an operator • User  operator • Add a card reader • Reduce setup time by batching similar jobs • Automatic job sequencing – automatically transfers control from one job to another. First rudimentary operating system. • Resident monitor • initial control in monitor • control transfers to job • when job completes control transfers back to monitor COP4610

  7. Memory Layout for a Simple Batch System COP4610

  8. Spooling • Overlap I/O of one job with computation of another job. While executing one job, the OS • Reads next job from card reader into a storage area on the disk (job queue). • Outputs printout of previous job from disk to printer. • Job pool – data structure that allows the OS to select which job to run next in order to increase CPU utilization COP4610

  9. Multi-programmed Batch Systems Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. COP4610

  10. OS Features for Multi-programming • I/O routine supplied by the system • Memory management – the system must allocate the memory to several jobs • CPU scheduling – the system must choose among several jobs ready to run • Allocation of devices COP4610

  11. Time-sharing Systems • The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory). • A job is swapped in and out of memory to the disk. • On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” not from a card reader, but rather from the user’s keyboard. • On-line system must be available for users to access data and code. COP4610

  12. Personal-computer Systems • Personal computers – computer system dedicated to a single user. • I/O devices – keyboards, mice, display screens, small printers. • User convenience and responsiveness. • Can adopt technology developed for larger operating system • often individuals have sole use of computer and do not need advanced CPU utilization of protection features. COP4610

  13. Parallel systems • Multiprocessor systems with more than one CPU in close communication. • Tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory. • Advantages of parallel system: • Increased throughput • Economical • Increased reliability • graceful degradation • fail-soft systems COP4610

  14. Real-time systems • Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems. • Well-defined fixed-time constraints. • Hard real-time system. • Secondary storage limited or absent, data stored in short-term memory, or read-only memory (ROM) • Conflicts with time-sharing systems, not supported by general-purpose operating systems. • Soft real-time system • Limited utility in industrial control or robotics • Useful in applications (multimedia, virtual reality) requiring advanced operating-system features. COP4610

  15. Distributed systems • Distribute the computation among several physical processors • Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines • Advantages of distributed systems • Resources Sharing • Computation speed up – load sharing • Reliability • Communications COP4610

  16. Distributed systems - cont. • Network operating system • provides file sharing • provides communication scheme • runs independently from other computers on the network • Distributed operating system • less autonomy between computers • gives the impression there is a single operating system controlling the network. COP4610

  17. Migration of Operating-System Concepts and Features COP4610

  18. Genesis of Modern OS COP4610

  19. Using the O.S. • For a programmer, the operating system interface is most important • The functions provided by the OS • Abstract resources that are available COP4610

  20. Requesting Services from O.S. • Two techniques • System call • Message passing COP4610

  21. Requesting Services – cont. • Two techniques • System call • Message passing COP4610

  22. System Call Interface • System call interface • Operating system provides a set of operations called system calls • A programming interface COP4610

  23. How to Make a System Call • For a programmer • A system call is similar to a procedure/function call in a traditional programming language • System calls are available in C/C++ as library routines • For example, fork to create a new process COP4610

  24. Do the parent and the child have the same sequence of instructions when fork() is successful? Why do we say this is the child and this the parent? How about here? How to Make a System Call – cont. pid = fork(); if (pid == ((pid_t)-1)) { // Something must be wrong with the fork // error processing ......... } else { if (pid == 0) { // This is the child process ........ } else { // This is the parent process ......... } //How about here, the parent or the child ? ........... } COP4610

  25. System Call Overview • man –s 2 intro • List of all the system calls available • Process management system calls • Memory management system calls • File and I/O system calls • Communication system calls • Information maintenance system calls COP4610

  26. Process Management System Calls • fork – Create a new process • exit – Terminate a process • wait – Wait for a child process to terminate • exec – Execute a file • nice – Change scheduling priority for a process • _lwp_create – Create a new lightweight process • yield – Yield execution to another lightweight process COP4610

  27. Memory Management System Calls • brk – Change the size of data segment of process • memcntl – Memory management control • mmap – Map pages of memory • (Memory mapped I/O) • Note: malloc and free are library functions using memory management system calls COP4610

  28. File Management System Calls • open – Open a file for reading or writing • creat – Create a new file and open it • read – Read bytes from an open file • write – Write bytes to an open file • close – Close an open file • seek – Change the location in the open file of the next read or write • stat – Get information about a file • mkdir – Make a directory • mount – Mount a file system COP4610

  29. File Management System Calls • open – Open a file for reading or writing • creat – Create a new file and open it • read – Read bytes from an open file • write – Write bytes to an open file • close – Close an open file • seek – Change the location in the open file of the next read or write • stat – Get information about a file • mkdir – Make a directory • mount – Mount a file system An open file is a dynamic object that can provide bytes from a file or accept bytes to be stored in the file. It has a set attributes, such as file pointer. It is a virtual device created by the operating system. Files however are passive containers of data COP4610

  30. I/O System Calls • open – Open a device for reading or writing • read – Read bytes from an open device • write – Write bytes to an open device • close – Close an open device • ioctl – Control device COP4610

  31. Communication System Calls • pipe – Create an inter-process channel • kill – Send a signal to a process or a group of processes • msgctl – Message control operations • shmat, shmctl, shmget, shmop – Shared memory operations • Semctl, semget, semop – Semaphore operations COP4610

  32. Information Maintenance System Calls • acct – Enable or disable process accounting • stime – Set system time and date • times – Get process and child process times • utimes – Set file times COP4610

  33. Interactive and Programming Interfaces • Interactive interfaces have advantages: • for exploration • for interactive use • Programming interfaces have advantages : • for detailed interactions • Inter-application programming • Scripting • It is useful for a program to have both interfaces COP4610

  34. Examples • Shell • Interactive interface to OS • System calls • Programming interface to OS COP4610

  35. Shell as an Interactive Interface • Interactive access to the OS system calls and system and user programs • cd to change current working directory • System call is chdir • Started by the system for a user • Contains a simple programming language • Popularized by UNIX • Bourne shell, C shell (csh), Korn shell (ksh), Bourne-again shell (bash), etc. COP4610

  36. Two views of a shell COP4610

  37. A Very Simple Shell • simple-shell.cc • The shell does the following steps repeatedly • Reads input from the user • Parses the user input according to predefined syntax • Interprets the internal commands such as cd and exit in the example • Runs external command, i.e., programs, for the user COP4610

  38. Summary • Operating system provides services to user programs through system calls • System call is implemented through a special instruction • A programming interface • Shell as an interactive interface to system calls and system and user programs COP4610

More Related