Context switch time is overhead system does no useful work while switching can

Context switch time is overhead system does no useful

This preview shows page 13 - 26 out of 56 pages.

Context-switch time is overhead; ° ± system does no useful work while switching ± can become a bottleneck ° Time for context switch is dependent on hardware support ( 1- 1000 microseconds).
Image of page 13
Process Creation ° Processes are created and deleted dynamically ° Process which creates another process is called a parent process; the created process is called a child process. ° Result is a tree of processes ° e.g. UNIX - processes have dependencies and form a hierarchy. ° Resources required when creating process ° CPU time, files, memory, I/O devices etc.
Image of page 14
UNIX Process Hierarchy
Image of page 15
Process Creation ° Resource sharing ± Parent and children share all resources. ± Children share subset of parent’s resources - prevents many processes from overloading the system. ± Parent and children share no resources. ° Execution ± Parent and child execute concurrently. ± Parent waits until child has terminated. ° Address Space ± Child process is duplicate of parent process. ± Child process has a program loaded into it.
Image of page 16
UNIX Process Creation ° Fork system call creates new processes ° execve system call is used after a fork to replace the processes memory space with a new program.
Image of page 17
Process Termination ° Process executes last statement and asks the operating system to delete it ( exit ). ± Output data from child to parent (via wait). ± Process’ resources are deallocated by operating system. ° Parent may terminate execution of child processes. ± Child has exceeded allocated resources. ± Task assigned to child is no longer required. ± Parent is exiting ² OS does not allow child to continue if parent terminates ² Cascading termination
Image of page 18
Threads ° Processes do not share resources well ± high context switching overhead ° A thread (or lightweight process) ± basic unit of CPU utilization; it consists of: ² program counter, register set and stack space ° A thread shares the following with peer threads: ² code section, data section and OS resources (open files, signals) ° Collectively called a task. ° Heavyweight process is a task with one thread.
Image of page 19
Single and Multithreaded Processes
Image of page 20
Benefits ° Responsiveness ° Resource Sharing ° Economy ° Utilization of MP Architectures
Image of page 21
Threads(Cont.) ° In a multiple threaded task, while one server thread is blocked and waiting, a second thread in the same task can run. ° Cooperation of multiple threads in the same job confers higher throughput and improved performance. ° Applications that require sharing a common buffer (i.e. producer-consumer) benefit from thread utilization. ° Threads provide a mechanism that allows sequential processes to make blocking system calls while also achieving parallelism.
Image of page 22
Threads (cont.) ° Thread context switch still requires a register set switch, but no memory management related work!! ° Thread states - ° ready, blocked, running, terminated ° Threads share CPU and only one thread can run at a time. ° No protection among threads.
Image of page 23
Threads (cont.) ° Kernel-supported threads (Mach and OS/2) ° User-level threads ° Hybrid approach implements both user-level and kernel-supported threads (Solaris 2).
Image of page 24
User Threads ° Thread management done by user-level threads library ° Supported above the kernel, via a set of library calls at the user level.
Image of page 25
Image of page 26

You've reached the end of your free preview.

Want to read all 56 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes