Understanding Operating System Processes and Creation Concepts

csci315 operating systems design department n.w
1 / 21
Embed
Share

Explore the fundamental concepts of processes and their creation in operating systems, with insights based on CSCI315 notes from Bucknell University. Learn about Unix structure, system calls, process execution, and forking in Unix environments.

  • Operating Systems
  • Processes
  • Unix
  • System Calls
  • Bucknell

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSCI315 Operating Systems Design Department of Computer Science Bucknell University Processes: Concepts and their Creation This set of notes is based on notes from the textbook authors, as well as L. Felipe Perrone, Joshua Stough, and other instructors. Xiannong Meng, Fall 2020. Ch 3

  2. We discuss the basic concept and creation of a process first, other topics later to fit the lab schedule.

  3. OS Services The entire blue area is operating system.

  4. Unix Structure

  5. System Calls and the OS Take the open() call as an example. $ man 2 open

  6. System Calls and Libraries printf() is a C library function. $ man 3 printf

  7. Process Concept Process a program in execution; the code in a process executes sequentially. A process includes: program counter, code, stack, heap, data section. stack heap Memory Map data program counter code

  8. All processes in Unix are created through fork()

  9. Forking (yeah, it s a thing, a Unix thing) Flow of execution Location where fork() is called. fork();

  10. Forking (yeah, it s a thing, a Unix thing) parent process Note that the child process and the parent process are identical at the moment of calling fork(). They differ when execution starts. Location where fork() is called. child process fork(); fork(); Location where fork() is called.

  11. Forking (what that return value is for) parent int pid; Location where fork() is called. pid = fork();

  12. Forking (what that return value is for) parent int pid; child pid = fork(); int pid; pid = fork(); what s the value of pid? what s the value of pid?

  13. Using fork safely int pid; pid = fork(); if (0 != pid) { // code of the parent } else { // code of the child }

  14. Using fork safely int pid; pid = fork(); if (0 != pid) { // code of parent P } else { // code of child C } P C

  15. Using fork safely int pid1, pid2; pid1 = fork(); if (0 != pid1) { // code of parent P } else { pid2 = fork(); // code of child C1 if (0 != pid2) { // more code of child C1, parent of C2 } else { // code of child C2 } P C1 C2

  16. Using fork even more safely int pid; pid = fork(); if (-1 == pid) { // error handling } else if (0 != pid) { // code of parent P } else { // code of child C } P C

  17. Joining processes in Unix

  18. Waiting (the inverse of forking) parent int s; child wait(&s); int s; exit(0);

  19. Waiting (the inverse of forking) parent int s; child parent waits wait(&s); int s; child executes exit(0);

  20. Waiting (the inverse of forking) parent int s; child parent waits wait(&s); int s; child exit(0); completed

  21. Waiting (the inverse of forking) parent int s; parent continues wait(&s);

Related


More Related Content