1 / 17

Chapter 3 – Processes

What is a process? A Program in execution A running program Maybe threads Always memory File descriptors. Chapter 3 – Processes. What does the OS Have to Do?. Create proc Delete/Kill Proc Start/Stop Proc Allocate RAM Allocate CPU time. How to make a windows process. STARTUPINFO si;

ochs
Download Presentation

Chapter 3 – Processes

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. What is a process? A Program in execution A running program Maybe threads Always memory File descriptors Chapter 3 – Processes

  2. What does the OS Have to Do? • Create proc • Delete/Kill Proc • Start/Stop Proc • Allocate RAM • Allocate CPU time

  3. How to make a windows process STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if (! CreateProcess ( TEXT("F:\\C++\\C++ Programs\\Hangman\\Debug\\Hangman.exe"), NULL,NULL,NULL,FALSE, CREATE_NEW_CONSOLE, NULL,NULL, &si, &pi ) ) { cout << "Unable to execute."; }

  4. Windows does it differently Faster but less flexible.

  5. What does a process look like in the kernel? • It’s a data structure • What RAM • What threads • What file descriptors • Process State/PC/CPU registers/Accounting/... • Etc. • Book says “Process control block”. Linux says “task_struct”. • http://lxr.linux.no/linux+v2.6.35/include/linux/sched.h#L1173

  6. How to make a process PID 1 is special Otherwise ...

  7. Fork/Exec

  8. Process Tree

  9. Process Tree

  10. Process Termination Call exit Make an error Have someone kill you Bruce Willis

  11. Process Control Block A Process Control Block is a data structure in the kernel that records information about the process. (struct task_struct in Linux) Process ID State (running, waiting) Memory CPU Registers User/Permission Which file descriptors Etc.

  12. Memory Maps • There is a thing called the MMU • It makes where ram is look different for each process. • Comes in a later chapter.

  13. Memory Map for a Process

  14. Multiple Processes for the same Program • Draw on board • What is shared? • What is not shared?

  15. Lifetime of a Process Draw Diagram Label causes of movement.

  16. Scheduling We multi-task (later chapter) Short Term Scheduler – the normal one Works on the millisecond basis Maximize work / Minimize latency Long Term Scheduler – if it exists Works on the minute/hour/day basis Keep the system not overloaded

  17. Definition: Context Switch Context switch: Change from running a thread or process to another. Interrupt gives kernel control, in privileged mode Stop the thread. Save state (CPU reg, PC, etc.) Change memory map Go back to user mode Load new state. Jump to resume other thread.

More Related