Notes - MIECT
Sistemas De Operação
Notes - MIECT
Sistemas De Operação
  • Sistemas de Operação
  • Processes in Unix/Linux
    • Process
    • Multiprocessing vs. Multiprogramming
    • Processes in Unix
    • Execution of a C/C++ program
  • Introduction to operating systems
    • Global view
    • Evolution of computational systems
    • Key topics
  • Semaphores and Shared memory
    • Concepts
    • Semaphores
    • Shared memory
    • Unix IPC primitives
  • Threads, mutexes and condition variables in Unix/Linux
    • Threads
      • In linux
    • Monitors
    • Unix IPC primitives
  • Processes
    • Process
      • Diagrams
    • Process control table
    • Context switching
    • Threads
  • Processor Scheduling
    • Processor Scheduler
    • Short-term processor scheduler
    • Scheduling algorithms
    • Scheduling criteria
    • Priorities
    • Scheduling policies
      • In Linux
  • Interprocess communication
    • Concepts
    • Philosopher dinner
    • Access primitives
      • Software solutions
      • Hardware solutions
    • Semaphores
    • Monitors
    • Message-passing
    • Unix IPC primitives
  • Deadlock
    • Introduction
    • Philosopher dinner - Solution 1
      • Deadlock prevention
    • Philosopher dinner - Solution 2
      • Deadlock prevention
    • Philosopher dinner - Solution 3
      • Deadlock prevention
    • Philosopher dinner - Solution 4
    • Deadlock avoidance
    • Deadlock detection
  • Memory management
    • Introduction
    • Address space
    • Contiguous memory allocation
    • Memory partitioning
    • Virtual memory system
    • Paging
    • Segmentation
    • Combining segmentation and paging
    • Page replacement
      • Policies
    • Working set
    • Thrashing
    • Demand paging vs. preparing
Powered by GitBook
On this page
  • Traditional login
  • Creation by cloning
  • Process creation: fork1
  • Process creation: fork2 and fork3
  • Launching a program: fork + exec
  1. Processes in Unix/Linux

Processes in Unix

PreviousMultiprocessing vs. MultiprogrammingNextExecution of a C/C++ program

Last updated 2 years ago

Traditional login

Creation by cloning

Process creation: fork1

The fork clones the executing process, creating a replica of it.

The address spaces of the two processes are equal.

  • actually, just after the fork, they are the same.

  • typically, a copy-on-write approach is followed.

The states of execution are the same.

  • including the program counter.

Some process variables are different (PID, PPID, ...).

Process creation: fork2 and fork3

The value returned by the fork is different in parent and child processes.

  • in the parent, it is the PID of the child.

  • in the child, it is always 0.

This return value can be used as a boolean variable.

  • so we can distinguish the code running on the child and parent.

In general, used alone, the fork is of little interest.

In general, we want to run a different program in the child.

  • exec system call.

  • there are different versions of exec.

Sometimes, we want the parent to wait for the conclusion of the program running in the child.

  • wait system call.

In this code, we are assuming the fork doesn’t fail.

  • in case of an error, it returns -1.

Launching a program: fork + exec