1 / 20

Lecture 10: Processes II-A

Lecture 10: Processes II-A. Process States Process vs. Thread Background/Foreground. Process States. We’ve mentioned these before: Running Idle/Sleeping Waiting for I/O Zombie Now a new one: Swapped Out. “Swapped Out” State. We only have so much CPU power

astin
Download Presentation

Lecture 10: Processes II-A

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. Lecture 10: Processes II-A • Process States • Process vs. Thread • Background/Foreground

  2. Process States • We’ve mentioned these before: • Running • Idle/Sleeping • Waiting for I/O • Zombie • Now a new one: • Swapped Out

  3. “Swapped Out” State • We only have so much CPU power • Can’t run everything at the same time • The processes must share • How do we decide who gets processor time? • Does this question sound familiar?

  4. “Swapped Out” State • We only have so much CPU power • Can’t run everything at the same time • The processes must share • How do we decide who gets processor time? • Does this question sound familiar? • Similar to memory management!

  5. Process Priority • Linux • “Niceness” level • -20 (greedy) to +20 (charitable) • Windows • IDLE_PRIORITY_CLASS • BELOW_NORMAL_PRIORITY_CLASS • NORMAL_PRIORITY_CLASS • ABOVE_NORMAL_PRIORITY_CLASS • HIGH_PRIORITY_CLASS • REALTIME_PRIORITY_CLASS

  6. Process Priority • Setting high priorities can be bad • Why?

  7. Process Priority • Setting high priorities can be bad • Why? • Other processes get neglected • Those other processes may be system processes • Neglected system processes can degrade performance of your process

  8. Process Management • On modern computers, we want to run tasks “simultaneously”… • …by interweaving • Single CPU • Appears simultaneous to us • …in parallel • Multiple CPUs • Truly simultaneous! • For upcoming slides, we’re interweaving

  9. Process • Created out of a program • Communicates with peers via interprocess communication • Low level: pipes, shared memory, etc • High level: MPI, ZeroMQ, etc • Lasts for “length of program”

  10. Thread • Created out of ________ • Communicates with peers • ? • Lasts for _________

  11. Thread • Created out of a process • Communicates with peers • ? • Lasts for _________

  12. Thread • Created out of a process • Communicates with peers • Shared memory space* • Lasts for ________ * Not generally referred to as “shared memory”

  13. Thread • Created out of a process • Communicates with peers • Shared memory space* • Lasts for length of code segment * Not generally referred to as “shared memory”

  14. Process Management • We want to run multiple processes simultaneously • Let’s restrict ourselves to single terminal • So far, we can… • …suspend a process • …resume a process • What else can I do? • Change background/foreground

  15. Background/Foreground • A terminal can run many jobs* • “Infinite” in the background • One in the foreground • By default, the job launches in the foreground • How do we get stuff in the background? * A “job” is a command we ran

  16. Background/Foreground • At process launch • Use the ampersand • find / -name “*.txt &” • While process is running • ctrl+z to suspend • bg %n • n is the job number • Use jobs command to discover job #s • bg executes/resumes job… • …but in background

  17. Background/Foreground • BG jobs • What happens to stdout/stderr? • What happens to stdin?

  18. Background/Foreground • BG jobs • What happens to stdout/stderr? • Still goes to specified place • Output can get mixed with BGs and FG • What happens to stdin?

  19. Background/Foreground • BG jobs • What happens to stdout/stderr? • Still goes to specified place • Output can get mixed with BGs and FG • What happens to stdin? • It doesn’t have access to it • How do we return stdin access to job?

  20. Background/Foreground • BG jobs • What happens to stdout/stderr? • Still goes to specified place • Output can get mixed with BGs and FG • What happens to stdin? • It doesn’t have access to it • How do we return stdin access to job? • Return it to foreground • fg %n

More Related