pid waitstatus else child exitstatus the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fork()) { /* parent */ ….. pid = wait(&status); } else { /* child */ ….. exit(status); } The fork syscall returns twice: it returns a zero to the child and the child process ID (pid) to the parent. Parent uses wait to sleep until the child exits; wait returns child pid and status. Wait variants allow wait on a child, or notification of stops and other signals. Process Process States CSci CSci 5103 Operating Systems Threads Threads: Threads: What are they? A thread is a basic unit of CPU utilization or execution defined by CPU register values (PC, SP) each thread must have its own stack suspend: suspend: save register values in memory resume: restore registers from memory Multiple threads can execute independently: They can run in parallel on multiple CPUs - physical concurrency … or arbitrarily interleaved on a single CPU - logical concurrency Threads Threads and Data Threads inside a process share state When When is data shared? • local variables are private: remember each thread gets its own own stack • global variables are shared • dynamic variabl...
View Full Document

This document was uploaded on 04/02/2014.

Ask a homework question - tutors are online