1 / 22

CMSC421: Principles of Operating Systems

CMSC421: Principles of Operating Systems. Nilanjan Banerjee. Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/. Principles of Operating Systems. Announcements. Readings from Silberchatz [3rd chapter ] Late Policy.

brenna
Télécharger la présentation

CMSC421: Principles of Operating Systems

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. CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating Systems

  2. Announcements • Readings from Silberchatz[3rd chapter] • Late Policy

  3. Processes

  4. Process Tree generation system process tree

  5. But what is a process? • An operating system executes a variety of programs: • Batch system – jobs • Time-shared systems – user programs or tasks • Textbook uses the terms job and process almost interchangeably • Process – a program in execution; process execution must progress in sequential fashion • A process includes: • program counter • stack • data section

  6. Process Memory looks like. virtual Address space why virtual?

  7. How do we create new processes in userland (fork) Lets see a demo

  8. What is really happening here

  9. Fork() primer into virtual memory management Virtual addresses (page table) unallocated Physical addresses

  10. Fork() Copy-on-write policy Physical addresses Parent process Child process

  11. Fork() Copy-on-write policy Physical addresses Parent process Child process write to a page

  12. communication child/parent process (Unnamed pipes) Pipe(fid); // where int fid[2] fid[0] is the read from the pipe and fid[1] is write to the pipe dup2(oldfid, newfid) //creates an alias to oldfid //very handy when you do not want to use file descriptors and use standard ones

  13. Process States • As a process executes, it changes state • new: The process is being created • running: Instructions are being executed • waiting: The process is waiting for some event to occur • ready: The process is waiting to be assigned to a processor • terminated: The process has finished execution

  14. Kernel data structure for processes (PCB) Information associated with each process • Process state (running, waiting, ready, terminated) • Program counter (instruction that is executing right now) • CPU registers (eax, ebx, etc) • CPU scheduling information (when would it scheduled) • Memory-management information (pages that are allocated, non-allocated, what do they correspond to) • Accounting information (several things like time created, time run, time waiting etc.) • I/O status information (file descriptors in addition to stdin, stdout, stderr, other files, pipe information, FIFO, shared memory, mmapedfile) get a plethora of information in /proc/<pid>/

  15. Kernel data structure for processes (PCB) Represented by the C structure task_struct pidtpid; /* process identifier */ long state; /* state of the process */ unsigned int time slice /* scheduling information */ struct task struct *parent; /* this process’s parent */ struct list head children; /* this process’s children */ struct files struct *files; /* list of open files */ struct mm struct *mm; /* address space of this pro */

  16. Process Context Switch • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch. • Context of a process represented in the PCB • Context-switch time is overhead; the system does no useful work while switching • The more complex the OS and the PCB -> longer the context switch • Time dependent on hardware support • Some hardware provides multiple sets of registers per CPU -> multiple contexts loaded at once

  17. Process Context Switch

  18. Process Scheduling

  19. Process Queues

  20. Lets take a kernel dive to study the process data structure and fork() system call duplicate task_struct Schedule child process

  21. Next class • Process management • Inter-process communication (Named pipes, shared memory (shmget, mmap), message passing) • Intro to threads

  22. An in-class discussion (a bit-hack)

More Related