40 Advanced Operating Systems Implementing System Calls.

Slides:



Advertisements
Similar presentations
CSCC69: Operating Systems
Advertisements

16 UNIX and Linux. Fig. 16.1: The shell and the kernel.
Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
Discussion Week 5 TA: Kyle Dewey. Overview HW 3.10 and 6.2 review Binary formats System call execution in NACHOS Memory management in NACHOS I/O in NACHOS.
Linking, Loading and Mapping A look at how Operating System utilities and services support application deployment.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Introduction to Kernel
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.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Embedded Control Systems Introduction to cross development techniques.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can.
Process Description and Control A process is sometimes called a task, it is a program in execution.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
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
System Calls. The Linux we use is: Linux-Mandrake 7.0. In this project, you are going to change some kernel files and recompile the kernel. After you.
1 Chapter 4 Processes R. C. Chang. 2 Linux Processes n Each process is represented by a task_struct data structure (task and process are terms that Linux.
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.
Kernel mode linux. Why? ● The pros – There is a C like interface inside the Linux kernel already. – The speed. – The size of AP. ● The cons – Missing.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Nachos Lecture 2 Xiaorui Sun. Phase 2 You have got one machine (machine package) You have to implements the incomplete OS (userprog package) Run programs.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
CSC 660: Advanced Operating Systems
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
What is a Process ? A program in execution.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 2.
System calls for Process management Process creation, termination, waiting.
Memory Management 백 일 우
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Introduction to Kernel
Protection of System Resources
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 5: Threads Overview Multithreading Models Threading Issues
Process Management.
CS 3305 System Calls Lecture 7.
Processes David Ferry, Chris Gill
Processes in Unix, Linux, and Windows
Structure of Processes
Processes in Unix, Linux, and Windows
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 2: The Linux System Part 2
More examples How many processes does this piece of code create?
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Tutorial: The Programming Interface
Operating Systems Lecture 3.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Chapter 5: Threads Overview Multithreading Models Threading Issues
Processes in Unix and Windows
CS510 Operating System Foundations
Process Description and Control in Unix
Process Description and Control in Unix
Processes David Ferry, Chris Gill, Brian Kocoloski
Presentation transcript:

40 Advanced Operating Systems Implementing System Calls

41 System Call Implementation Under Linux system calls have 2 separate function calls –The do_xxx call which does the work –The sys_xxx macro which deals with arguments a call numbers

42 System Call Implementation System calls involve switching from user to supervisor mode through an interrrupt (0x80 on PCs) _syscall macro generates the actual system call number (unistd.h) Interrupt routine handles the call (arch/kernel/entry.s) If legitimate, the routine looked up in sys_call_table[]

43 System Call Implementation Some call may be traced - ie debugged calls – using the syscall_trace function On return from system call a number of administrative tasks must be done –Send parent signals –Any pending interrupt service routines called –Signals handled

44 Implementing fork() & clone() Under Linux fork() and clone() are essentially the same call with some (important) differences –Fork() create a completely new process –Clone() creates a new thread within a process

45 Linux fork() versus traditional fork() UNIX fork() creates –New process environment –Copies data –Copies text* –Copies files, locks and signals –Creates new PID Linux fork() creates –New process environment –Makes data write protected (copies on write) –Copies files, locks and signals –Creates new PID * Text may be shared

46 Implementing fork() & clone() They both call do_fork() however clone() sets up some extra parameters beforehand –Set up a new set of register and stack pointers do_fork() is called as follows –do_fork(SIGCHILD, regs, esp, &regs); Or –do_fork(clone_flags, newsp, &regs);

47 Implementing fork() & clone() do_fork() –Creates a new stack –using kmalloc() –Gets a new process table entry The child or thread inherits all of the parents task structure but changes some entries –Exec flag, time, signal flags

48 Implementing fork() & clone() The difference between fork and clone is found at the final section of the call – when the task substructures are copied (or not!) –This copies files, file systems, signal handlers, memory management –The parent gets the child or thread pid

49 Fork and Clone Kernel Thread Process 1 User Space Kernel Space

50 Executable formats Before looking at exec a word on file formats – there are a number of different formats –a.out – the original UNIX format –COFF – Common Object File Format –ELF – Executable and Linkable Format There are others – lots of them!

51 Linux and file formats Linux supports a large number of file formats – each ones is tried until one works –Done by do_exec –Use linux_binfmt Loads binary Loads libs Deals with the core file They can be load as modules

52 ELF p_type p_offset p_vaddr p_filesz p_memsz p_flags p_type p_offset p_vaddr p_filesz p_memsz p_flags CODE DATA ‘E’ ‘L’ ‘F’ 0x e_indent e_entry e_phoff e_phentsize e_phnum PT_LOAD 0 0x PF_R, PF_X PT_LOAD x8059BB PF_R, PF_W Physical Header Physical Header