Docsity

Operating Systems: Processes, Threads, and System Calls, Lecture notes of Operating Systems

Partial preview of the text

Download Operating Systems: Processes, Threads, and System Calls and more Lecture notes Operating Systems in PDF only on Docsity!

file from^ the disk (^) , and also^ considering

what

can go (^) wrong while reading a disk^ block (^). That's why an

interface

was needed^ with which user can^ interact^ and^ do his work So (^) ,^ the^ most^ fundamental system program

introduced

is OPERATING^ SYSTEM. Application (^) programs are but^ on^ top of the^ os. ④ ·

BANKING (^) AIRLINE (^) BROWSER & Application (^) programs SYSTEM (^) RESERVAT... RETER

I

COMPILERS EDITORS

INTERP

I

Operating systems^

system (^) programs Machine (^) language Hardware Micro-architecture

Physical devices

Kernel mode^ Os^ is^ that^ portion of

sys (^) program which run in^ Kernel^ mode^ or^ supervised mode^ , which means user^ programs can't temper the hardware becz user prog.

run in user^ mode.

Operating system^ handles (^) so many complex operations . And (^) resource managment

includes

multiplexing d Time multiplexing space^

mult.

M programsp2-

    • scheduling processes^ on
  • II/II^ CPU

P1 (^) //// >

  • To sea

[Time multiplexing]

  • > time P

* scheduling/providing

mem (^). p to programs O (^1024) bytes [space multiplexing]

MINN We^ will study

MINIX Os and^ will^ code^ also

-- if possible^ so that^ everything we'll understand in a great

detail and can

benefit (^) from it lifelong MINIX is inspired (^) from UNIX^

os because UNIX

did

change license to^ not^ use it for any

University

course or

study (^) purpose . It is^ written^ in^ c-language

. (^) MINIX impired (^) , LINUX originated (^) from MINIX only after a person name "Linus Torvalds"^ made^ few changes

in MINIX and

Linux 1. 0 born (^) on March^13 , 1994.

#SYSEM CALLS FOR PROCESS (^) MANMENTS E

pid

fork 2

  • > creates^ a^ child^ process identical^ to parent pid = waitpid (pid^ , &^ staloc^ , (^) opts)
  • > wilt^ for child^ to (^) terminate = execue^ (name^ , (^) argr , envp)
  • > replace a process core image exit(status)
  • > terminate^ proces execution and^ return^ status sizez bri(addr)^
  • > set the size (^) of the^ data^ segment pid = getpid()
  • > return^ the^ caller's process id
  • > returns caller's proces group

id

pid

getgrp)) pid = (^) setsid()

  • > creates^ a^ new^ session^ If^ returns^

its proc.

id

group 1 =^ Ptrace^ (req ,^ pid , addr^ , datase used^ to^ get trac & (^) debugging

① for forkil

  • > at^ the^ time

registers ,^ fas^ ... of (^) for king (^) rt , r , fl,^ f^ -1 (^) , r2^ , (^) f1 , (^) + 2 & everything same everything is same including registers , (^) fols &^ variable's (^) values ·

  • >

when both^ runs^ , (^) they run^ separately

and state

change of one (^) doesn't effect

another-

pid

fork)) returns o for child If child's (^) PID (^) for the

parent

running

a command^ shell^ is

  • > after child process's completion^ the (^) address pointed out by "statlos" will^ have^ child's^ termination^

status. 4 normal (^) , abnormal^ or^ exit^ values Now (^) , when^ child (^) executes the user command^ -^ > It does^ so by (^) calling exece system call 8 -^

# define TRUE^1

·Levelworking (^) while[TRUES & typeprompt (^2) ;

[C-Program] readCommand()^ ;

-- parent waiting^ [if

(tork()!^

= (^) 6) (^) & waitpid (1, &^ Status , of^ ;^3 chidetecting

the

<-[elsed execre [commd (^) , parame , of t y

execre) name^ , argy , exp (^) Ent Note i ↓ name (^) of

the

file to be^ executed I wa willeen pointer to t

the

arg (^) array too- -- ↓ -- pointer to (^) the env array

  • > exit^ (status) It has^ value^ 0-
  • > It is^ need^

by

the

processes

to

exit/terminate and status returned^ will^ go/store

to the^ adds^

pointed out byOstatic . IWill be returned (^) to the (^) parent-

· (^) signals can^ be^ blocked^ in^ MINIX ⑧ Blocked^ signal

are held

pending

until unblocked

④ (^) sigpending)) call^ return a (^) set of bitmap 20 ,^ 1 , 1 , (^04)

to

represent the signals

which one

pending and blocked ④ sigprocmask)) call (^) allows a process to define a (^) set of (^) bitmap for landl to (^) tell the^ blocked signals ⑤ Insted^ using a function by^ a proces

, the^

procee an define a constant SIG-IGN to^ tell that signals (^) of (^) specific type one^ blocked/ignored .

⑳ S12-DFL^ is^ to^ restore^ the^

default action of

the

signal when^ it (^) occurs.

· (^) the

default

action of the signal is either^

kill the^ process or ignore the (^) signal which depends on the signal .

  • while^ running amand In the
  • -^ background--

"Command &

"

  • > shell^ forks a^ child^ process ④ cusing fork) runs the command (^) (using exec) & After the forkl^ but (^) before running

the command-

using

execc) ,

the shell^ does

sigacion (SIGINT^ ,^ 512-14N (^) , NULL) /sigaction

(SIGQUI, SIG-IGN,

NULL)

  • > unrelated^ processes can^ not^ signal each other^.
  • > By (^) sending signal^ (^9) (S14KILL) [Kill-9 <^ pick]
  • > In real life , many a (^) time a process is required to do^ something after

an interval

of

time. for

this SIGALARM is used

② (^) ①

  • SYSTEM^ CALLS^ FOR^ FILE^ MANAGEMENT^87
  • fd = (^) creat (^) ("abs" , 0751) creates a file with "abs" (^) as name and (^) with -

rights (^) represented (^) by (^0751).

↓ represents^ rux bits

di O in^ C represents that I 78

= FX

O

constant is^ in^ octal

18 =^ 2001 2^
= 7 =^ III

⑳ rWX^ - >^ read^ , write , executable permissions #Y^ , 0

  • (^) = 7 x1oF (^) +

④ (^) owner(7)^

  • > (^) rwx permission

4 X 100

1120 = (^) (x82 + · (^) his grou (5)

  • > vx (^) permission (xd + · others (1)^
  • > (^) x pemission 2x ↓