This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Unix system calls (part 1) history and.

Slides:



Advertisements
Similar presentations
1 Processes and Threads Creation and Termination States Usage Implementations.
Advertisements

Process Management.
The UNIX File System Harry Chen Department of CSEE University of MD Baltimore County.
Chapter 6 File Systems 6.1 Files 6.2 Directories
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Slide 2-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 2 Using the Operating System 2.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Unix system calls (part 2)
Basic Unix system administration
The Environment of a UNIX Process. Introduction How is main() called? How are arguments passed? Memory layout? Memory allocation? Environment variables.
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
1 Processes Professor Jennifer Rexford
1 UNIX 1 History of UNIX 2 Overview of UNIX 3 Processes in UNIX 4 Memory management in UNIX 5 The UNIX file system 6 Input/output in UNIX.
Processes CSCI 444/544 Operating Systems Fall 2008.
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
1 Case Study 1: UNIX and LINUX Chapter History of unix 10.2 Overview of unix 10.3 Processes in unix 10.4 Memory management in unix 10.5 Input/output.
CSE451 Section 7: Virtual memory. Table of content Real address space Process creation optimization Debugging: watch point.
1 CS 333 Introduction to Operating Systems Class 2 – OS-Related Hardware & Software The Process Concept Jonathan Walpole Computer Science Portland State.
Introduction to Kernel
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Linux Operating System
Phones OFF Please Processes Parminder Singh Kang Home:
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
Chapter 3 Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes Tarek Abdelzaher Vikram Adve.
hardware and operating systems basics.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Introduction to Processes CS Intoduction to Operating Systems.
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
4P13 Week 3 Talking Points 1. Process State 2 Process Structure Catagories – Process identification: the PID and the parent PID – Signal state: signals.
System calls for Process management
CS 153 Design of Operating Systems Spring 2015 Lecture 5: Processes and Threads.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Operating Systems Process Creation
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Unix System Calls and Posix Threads.
Linux Commands C151 Multi-User Operating Systems.
Processes and Virtual Memory
What is a Process ? A program in execution.
System calls for Process management Process creation, termination, waiting.
Week 4 - Friday.  What did we talk about last time?  Some extra systems programming stuff  Scope.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
Let’s look at an example
Introduction to Kernel
Linux 101 Training Module Linux Basics.
Process Management Process Concept Why only the global variables?
Protection of System Resources
Linux Processes & Threads
Process Management Presented By Aditya Gupta Assistant Professor
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
Lecture 5: Process Creation
System Structure B. Ramamurthy.
Making Virtual Memory Real: The Linux-x86-64 way
More examples How many processes does this piece of code create?
System Structure and Process Model
Lab 5 Process Control Operating System Lab.
Process Creation Process Termination
Department of School of Computing and Engineering
UNIX Introduction.
Lecture 6: Multiprogramming and Context Switching
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Process Description and Control in Unix
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Unix system calls (part 1) history and usage of Python basic data types and the type hierarchy syntax modules and variable scopes

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Unix system calls (part 1)

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. This is one part of a larger series. You may need to view previous parts to understand this material.

It’s a Unix system!

System V BSD 1980’s

Linux Mac OS X FreeBSD, OpenBSD today

POSIX (Portable Operating System Interface for Unix) SUS (Single Unix Specification)

Process C Process B kernel Process A jump to system call code via special instruction RAM

0x system call 0 0x system call 1 0x system call 2 0xA system call 3 0xFF system call 4 0xFF system call 5 0xFF system call 6 0xFF system call 7 ……

stack code heap kernel code  pages only accessible in system calls jump to system call code via special instruction

frame of main frame of cat frame of dog frame of fish stack space frame of syscall

created waitingrunning blocked terminated

processes files networking sockets signals inter-process communication terminals threads I/O devices

ssize_t read(int fd, void *buf, size_t count);

read(fd)

process: address space user ids file descriptors environment current and root directory stack heap code heap

stack code initialized data heap kernel code uninitialized data  global variables with initial values  global variables without initial values

stack code initialized data heap kernel code uninitialized data  a.k.a. the “text”  global variables with initial values  global variables without initial values  starts empty, grows automatically  explicitly allocated during execution

mmap (‘memory map’ pages to the process address space) munmap (‘memory unmap’ pages from the process address space)

mmap (‘memory map’ pages to the process address space) munmap (‘memory unmap’ pages from the process address space) address = mmap(5000) … # do stuff with memory at address munmap(address)

stack code initialized data heap kernel code uninitialized data heap mmap fails when not enough space

if fork() == 0: … // new (child) process else: … // original (parent) process

RAM byte 0 byte n HD stack heap code heap fork

stack heap code heap RAM byte 0 byte n HD stack heap code heap fork

stack heap code heap RAM byte 0 byte n HD stack heap code heap fork

stack heap code heap RAM byte 0 byte n HD stack heap code heap write  fork

stack heap code heap RAM byte 0 byte n HD stack heap code heap copy write  fork

stack heap code heap exec

code exec (executable)

if fork() == 0: // new (child) process exec(‘/games/pong’) else: … // original (parent) process

pid 1 (init) pid 85 pid 17 pid 24pid 230 pid 104 pid 34 pid 50

_exit (terminate the process) _exit(0)

wait (block the process until child process terminates) pid = fork() if pid == 0: // new (child) process exec(‘/games/pong’) else: // original (parent) process code = wait(pid)

TERM=xterm SHELL=/bin/bash USER=greys MAIL=/var/mail/ted PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin PWD=/home/ted EDITOR=vim name=value

pid 1 (init), user 0 pid 85, user 8 pid 17, user 4 pid 24, user 33pid 230, user 8 pid 104, user 33 pid 34, user 4 pid 50, user 4

user accounts: /etc/passwd

user accounts: /etc/passwd superuser/root = user id 0 privileged to do anything it wants

each process has three user ids: each file and directory is owned by a single user “real” id: the owning user “effective” id: determines privileges “saved” id: set by exec to match the effective id

exec (sets effective and saved ids when binary file has setuid bit)

seteuid (sets effective user id) setuid (sets real, effective, and saved user ids)

exec (sets effective and saved ids when binary file has setuid bit) seteuid (sets effective user id) setuid (sets real, effective, and saved user ids) non-superuser can only directly set effective id to match the real or saved id

pid 1 (init), user 0 pid 3 (shell), user 1780 pid 2 (login), user 0

pid 1 (init), user 0 pid 3 (shell), user 1780 pid 2 (login), user 0 fork, exec

pid 1 (init), user 0 pid 3 (shell), user 1780 pid 2 (login), user 0 fork, exec fork, setuid, exec

user groups: /etc/group user may belong to multiple groups but has one “primary” group each file and directory is owned by one group each process has a real, effective, and saved group id binary files have setgid bit setegid and setgid

rwx rwx rwx usergroupother

rwx rwx rwx usergroupother if file_user_id == effective_user_id: user class else if file_group_id == effective_group_id: group class else: other

file permissions: read: can read bytes of file write: can modify bytes of file execute: can exec file

directory permissions: read: can get names of files write: can add/remove/rename files execute: can use in file paths

directory permissions: read: can get names of files write: can add/remove/rename files execute: can use in file paths /adams/taft/garfield/eisenhower

directory permissions: read: can get names of files write: can add/remove/rename files execute: can use in file paths /adams/taft/garfield/eisenhower /adams/taft/ (OK)

r-xr-xr-x rw-r----- r-x--x--x rwx /adams/lincoln /adams/cleveland /roosevelt /fillmore rwx rwx rwx usergroupother

dr-xrw-r-x /adams/ rwx rwx rwx usergroupother

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.