clone() and fork() - clone() and fork() Clone and fork...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
clone() and fork() Clone and fork create a new task. clone – Creates a new task using the same memory mapping and file descriptors of the parent task. Used to create a new thread in the same process. fork – Creates a new task using a copy of the memory mappings (with copy-on-write) and a copy of the file descriptors of the parent task. This is used to create a new process.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Steps for fork/clone 1. If number of tasks is exceeded return EAGAIN. 2. Allocate new task struct with p = alloc_task_struct() 3. Copy values of current process into new task *p = * current 4. Set process id of the task. 5. If fork() make a copy of mm struct and make copy on write mappings of pages shared with parent. 6. If fork(), create a copy of files_struct files with open files. Close files that are not shared with parent. Object files will be shared but not open files. 7. If fork() return 0 in the child and the new_pid in the
Background image of page 2
Exiting a Process A process is terminated when Making a exit() system call
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2012 for the course CS 354 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 6

clone() and fork() - clone() and fork() Clone and fork...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online