Presentation is loading. Please wait.

Presentation is loading. Please wait.

CGS 3763 Operating Systems Concepts Spring 2013

Similar presentations


Presentation on theme: "CGS 3763 Operating Systems Concepts Spring 2013"— Presentation transcript:

1 CGS 3763 Operating Systems Concepts Spring 2013
Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM

2 Lecture 11 – Friday, February 1, 2013
Last time: Context switching Kernel functions for process management Today: Answers to student questions Creation and termination of processes Inter-process communication Shared memory Message passing Next time Sockets Client-server systems Remote procedure call Reading assignments Chapters 3 and 4 of the textbook Chapters 3 and 4 textbook slides 11/24/2018

3 Student Review Form Week 3 Summary
Jan 23th Wednesday: Virtual memory and virtual address space – more in depth explanation How does virtual memory map to real memory? How does branch execution work? The register files and ALU wasn’t explained thoroughly enough Jan 25th Friday: What does the PCB do? Does a layered system and a modular system have pros/cons More clarification on the way interrupts work within the Hardware and the OS. 11/24/2018

4 11/24/2018

5 11/24/2018

6 11/24/2018

7 Branch instructions Status register/flag register/condition code register/program status word (PSW)  a collection of flag bits for a processor. Arithmetic and logic instructions setup condition code. A branch instruction tests such flags. Example SR R1,R2 (subtract the contents of R2 from R1. Result in R1) BZ kiki (if the result is 0 branch to instruction identified by label “kiki”) What happens to the PC (Program counter) - If the result is not 0 execute the next instruction PC  PC + 4 ( for a 32 bit architecture) PC  PC + 8 ( for a 64 bit architecture) - If the result is 0 execute the instruction at address “kiki” PC  the address of the instruction identified by label “kiki” 11/24/2018

8 Flags/condition codes
11/24/2018

9 Interrupts Hardware Software 11/24/2018

10 Process Creation A parent process create children processes, which, in turn create other processes, forming a tree of processes A process is identified by a process identifier (pid) Possible resource sharing strategies between parent and children Parent and children share all resources Children share subset of parent’s resources Parent and child share no resources Execution Parent and children execute concurrently Parent waits until children terminate

11 Process Creation (Cont’d)
Address space Child duplicate of parent Child has a program loaded into it UNIX examples fork system call creates new process exec system call used after a fork to replace the process’ memory space with a new program

12 Process Creation

13 C Program Forking Separate Process
int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); else { /* parent process */ /* parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0);

14 A tree of processes on a typical Solaris

15 Process Termination Process executes last statement and asks the operating system to delete it (exit) Output data from child to parent (via wait) Process’ resources are deallocated by operating system Parent may terminate execution of children processes (abort) Child has exceeded allocated resources Task assigned to child is no longer required If parent is exiting Some operating system do not allow child to continue if its parent terminates All children terminated - cascading termination

16 Interprocess communication
Processes within a system may be independent cooperating A process can affect or be affected by other processes, including sharing data Reasons for cooperating processes: Information sharing Computation speedup Modularity Convenience IPC - interprocess communication. Two models: Shared memory Message passing

17 Communications Models

18 Message passing Processes must have a way to refer to each other.
Direct communication  a process must explicitly name the recipient or sender of the communication: send(P, message) -Send a message to process P. receive (Q, message)-Receive a message from process Q. Indirect communication  messages are sent to and received from mailboxes, or ports. send (A, message) -Send a message to mailbox A. receive (A, message)-Receive a message from mailbox A. 11/24/2018

19 If a message is sent to a mailbox
If the mailbox is not full, the message is copied to the mailbox, and the sending thread continues. If the mailbox is full, the sending thread has four options: Wait indefinitely until there is room in the mailbox. Wait at most n milliseconds. Do not wait at all but rather return immediately. Temporarily cache a message. One message can be given to the operating system to keep, even though the mailbox to which that message is being sent is full. When the message can be put in the mailbox, a message is sent back to the sender; only one such message to a full mailbox can be pending at any time for a given sending thread. 11/24/2018

20 Producer-Consumer Problem
Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process unbounded-buffer places no practical limit on the size of the buffer bounded-buffer assumes that there is a fixed buffer size


Download ppt "CGS 3763 Operating Systems Concepts Spring 2013"

Similar presentations


Ads by Google