{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 2 Processes & Treads

Lecture 2 Processes & Treads - Administrivia Lab 1 is...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Administrivia Lab 1 is up, Due Thursday, Jan. 21 - Due at start of lecture – 4:15pm - Free extension to midnight if you come to lecture - Or for SCPD students if you watch lecture that day Ask cs140-staff for extension if you can’t finish - Tell us where you are with the project - And how much longer you need to finish No credit for late assignments w/o extension Section tomorrow, 3:15pm (here) 1/45
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Processes A process is an instance of a program running Modern OSes run multiple processes simultaneously Examples (can all run simultaneously): - gcc file A.c – compiler running on file A - gcc file B.c – compiler running on file B - emacs – text editor - firefox – web browser Non-examples (implemented as one process): - Multiple firefox windows or emacs frames (still one process) Why processes? - Simplicity of programming - Higher throughput (better CPU utilization), lower latency 2/45
Background image of page 2
Speed Multiple processes can increase CPU utilization - Overlap one process’s computation with another’s wait Multiple processes can reduce latency - Running A then B requires 100 sec for B to complete - Running A and B concurrently makes B finish faster - A slightly slower, but less than 100 sec unless A and B both completely CPU-bound 3/45
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Processes in the real world Processes, parallelism fact of life much longer than OSes have been around - E.g., say takes 1 worker 10 months to make 1 widget - Company may hire 100 workers to make 10,000 widgets - Latency for first widget >> 1/10 month - Throughput may be < 10 widgets per month (if can’t perfectly parallelize task) - Or > 10 widgets per month if better utilization (e.g., 100 workers on 10,000 widgets never idly waiting for paint to dry) You will see this with Pintos - Don’t expect labs to take 1/3 time with three people 4/45
Background image of page 4
A process’s view of the world Each process has own view of machine - Its own address space - Its own open files - Its own virtual CPU (through preemptive multitasking) *(char *)0xc000 different in P 1 & P 2 Greatly simplifies programming model - gcc does not care that firefox is running Sometimes want interaction between processes - Simplest is through files: emacs edits file, gcc compiles it - More complicated: Shell/command, Window manager/app. 5/45
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Inter-Process Communication How can processes interact in real time? (a) By passing messages through the kernel (b) By sharing a region of physical memory (c) Through asynchronous signals or alerts 6/45
Background image of page 6
Rest of lecture User view of processes - Crash course in basic Unix/Linux system call interface - How to create, kill, and communicate between processes Kernel view of processes - Implementing processes in the kernel Threads How to implement threads 7/45
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
UNIX files I/O Applications “open” files (or devices) by name - I/O happens through open files int open(char *path, int flags, /*mode*/...); - flags : O RDONLY , O WRONLY , O RDWR - O CREAT : create the file if non-existent - O EXCL : (w. O CREAT ) create if file exists already - O TRUNC : Truncate the file - O APPEND : Start writing from end of file - mode : final argument with O CREAT Returns file descriptor—used for all I/O to file 8/45
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}