0% found this document useful (0 votes)
37 views

Why Processes? Simplicity: Emacs Emacs

Processes provide isolated address spaces to separate programs from each other for security and reliability. They also allow for parallelism through overlapping execution which improves speed by allowing one CPU to act like multiple CPUs. A process is the running instance of a program and contains the program state including registers, stack, and heap.

Uploaded by

Kritarth Anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Why Processes? Simplicity: Emacs Emacs

Processes provide isolated address spaces to separate programs from each other for security and reliability. They also allow for parallelism through overlapping execution which improves speed by allowing one CPU to act like multiple CPUs. A process is the running instance of a program and contains the program state including registers, stack, and heap.

Uploaded by

Kritarth Anand
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Why processes?

Simplicity

nfsd www emacs


nfsd
OS
gcc
lswwwemacs ls lpr
lpr
OS
Processes give isolated Address Spaces
nfsd www emacs lpr ls
OS

Physical Memory (Paging)

Physical Memory (Segmentation)


Why processes? Speed
• I/O parallelism:
emacs (wait for input) (wait for input)

gcc
overlap execution: make 1 CPU into many
(Real parallelism: > 1 CPU (multiprocessing))
• Completion time: 80 s 20 s
A B
B’s completion time = 100s (A + B). So overlap
A
B 10 s Completion time for B? A?
Process != Program
• Program: code + data int a;
passive int main() {
printf(“hello”);
}

• Process: running program


stack
state: registers, stack, heap…
position: program counter
• We both run netscape: heap
data int a;
Same program, different process
code main()
The multithreading illusion
• Each thread has its illusion of own CPU
– yet on a uni-processor, all threads share the same
physical CPU!

How does this work?

• Two key pieces: CPU


– thread control block: one per thread, holds execution
state
– dispatching loop: while(1)
interrupt thread
save state
get next thread
load state, jump to it
Remote Procedure Call (RPC)
Comparison
P1:
P1:
calls send(args) [2]
sets up args in regs
calls recv(), blocks [1]
calls yield(P2) [1]
P2:
P2:
calls recv(args) [2]
resumes [1]
… does work …
… does work …
calls send(results) [2]
sets up results in regs
P1: calls yield(P1) [1]
P1:
recv() returns [1]
resumes [1]

Monolithic Kernel: around [8] total ExoKernel: around [4] total


user/kernel crossings user/kernel crossings

You might also like