CS 1550 Lecture 2: CS 1550 Scheduling

78 views8 pages
7 Feb 2017
School
Course

For unlimited access to Class Notes, a Class+ subscription is required.

Scheduling
Multiprogramming
Only way to truly run programs simultaneously, in parallel, is with multiple CPUs
CPU can run billions of instructions per second
o Enough to run processes in pseudo parallel
Process Table
Tracks all processes
Contains items needed for process management, file management, and memory
management
Threads
Can communicate without use of OS (through their address space)
Lightweight
Stacks for each thread, plus heap
Each thread has a max stack
Multithreading
o Word processor
Tasks all working together
Cooperative work & sharing information
o Webserver
Requests can be done in parallel
Multiprocessor web servers also exist
Depends on what we want: isolation or cooperation
User Threads vs. Kernel Threads
o OS choice (pthread library is a layer on top of this choice. Meant to protect
user from caring how the OS chooses)
o Modern OS
o Hybrid: implement kernel threading
Need the option of kernel threading
o pthread in both, but the implementation is different for each
Abstraction is supposed to hide the implementation
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 8 pages and 3 million more documents.

Already have an account? Log in
2
Insert pthread yields no matter what
o Kernel
OS has full support for every thread operation (creating and
managing)
Everything to make threading work
Scanf blocked issue: without support from OS this is unsolvable
We want a way to side step blocking (non-blocking syscall)
o Change scanf implementation
Will this block? If so, it'll run a ready thread.
And keep checking if it'll block.
Add this function to the threading library
Pros:
Cons:
Function call requires syscall (costly)
All threads and processes managed by same scheduling
algorithm
Pthread can be in the program because it is a suggestion (it won't
do anything)
o User
OS provides no support for threads at all
Support comes entirely from a library that an application
needing threads links against
Pros:
Easier to call a function (in address space already)
Better performance
Modularity
o Choice of scheduling algorithm for independent
threads
Cons:
More address space needed (not really a big issue)
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 8 pages and 3 million more documents.

Already have an account? Log in
3
Have to trust threads to share address space and CPU time
o If they don't, it affects the program, the OS doesn't
care
Infinite Loop
o Hardware interrupt, we end up back in infinite loop
(program counter is there)
Creates greed, other threads can't run
Can be fixed with pthread yield (take us to
library to perform scheduling
Scheduling
How to choose a ready process/thread
Data & code needs to be in RAM before execution
CPU Bound vs. I/O Bound
o CPU: program spends most of it's time doing computation
User time: time program uses executing instructions
Illusion that processes are running in parallel might go away
We fix this through preemption
Must consider cost
Could take more time than needed
Might be more efficient to just run them
sequentially
Overhead on top of overhead
Don't block because it's necessary, block to preserve
the illusion of parallelism
o I/O: program spends most of it's time waiting for I/O
Tiny user time
Preemption isn't necessary
System calls are necessary (OS isn't overhead). Program needs
data, so OS must be involve
How do we know most processes are I/O?
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 8 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class