System Calls System calls are the user API to the OS

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 3 Operating System Organization.
Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection.
Chap 2 System Structures.
SLC/Ver1.0/OS CONCEPTS/Oct'991INTRODUCTION What is an Operating System? Operating Structure -System Components -OS Services -System Calls & Programs -System.
Operating System Structure
Operating-System Structures
1 OS Structure, Processes & Process Management. 2 Recap OS functions  Coordinator  Protection  Communication  Resource management  Service provider.
Introduction to Kernel
Embedded Real-time Systems The Linux kernel. The Operating System Kernel Resident in memory, privileged mode System calls offer general purpose services.
OS Spring’03 Introduction Operating Systems Spring 2003.
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.
Figure 1.1 Interaction between applications and the operating system.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Operating-System Structures. Operating System Services Operating systems provide an environment for execution of programs and services to programs and.
LINUX System : Lecture 7 Bong-Soo Sohn Lecture notes acknowledgement : The design of UNIX Operating System.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
Silberschatz, Galvin and Gagne  Operating System Concepts UNIT II Operating System Services.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CSCE451/851 Introduction to Operating Systems
Introduction to Operating Systems Concepts
Exceptional Control Flow
Introduction to Operating Systems
CS 3214 Computer Systems Lecture 9 Godmar Back.
Introduction to Kernel
Processes and threads.
Interrupts and signals
Operating Systems CMPSC 473
Credits: 3 CIE: 50 Marks SEE:100 Marks Lab: Embedded and IOT Lab
CS 6560: Operating Systems Design
Chapter 2: Operating-System Structures
Protection of System Resources
Lecture 4: Operating System Structures
Chapter 2: System Structures
CS 3305 System Calls Lecture 7.
Operating Systems: A Modern Perspective, Chapter 6
Exceptional Control Flow: System Calls, Page Faults etc.
Chapter 15, Exploring the Digital Domain
More examples How many processes does this piece of code create?
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Mid Term review CSC345.
Chapter 1 Introduction to Operating System Part 5
Lecture Topics: 11/1 General Operating System Concepts Processes
Threads Chapter 4.
Chapter 2: Operating-System Structures
Operating Systems Lecture 3.
Concurrency, Processes and Threads
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
Operating Systems: A Modern Perspective, Chapter 3
Chapter 2: Operating-System Structures
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 2: Operating-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Operating - System Structures
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Chapter 3: Process Management
III. Operating System Structures
Presentation transcript:

System Calls System calls are the user API to the OS CSCE 410/611 System calls are the user API to the OS System calls are not function calls! How are system calls invoked? Why are system calls implemented this way? System Calls

Operating System Interfaces: System Calls CSCE 410/611 Operating System Interfaces: System Calls applications programs/ processes system call system call interface scheduler file system kernel memory manager etc. device drivers hardware System Calls

Types of System Calls File Management Device Management CSCE 410/611 Types of System Calls File Management create file, delete file open, close read, write, reposition get/set file attributes Process Control load execute end, abort create process terminate process get/set process attributes wait for time, wait event, signal event allocate, free memory Device Management request device, release device read, write, reposition get/set device attributes logically attach or detach devices Information Maintenance get/set time or date get/set system data get/set process, file, or device attributes Communication create, delete communication connection send, receive messages transfer status information attach or detach remote devices System Calls

System Calls – They look like Functions ... CSCE 410/611 System Calls – They look like Functions ... #include<unistd.h> int main(void) { write(1, "Hello, world\n", 13); return 0; } System Calls

... but they are not! Making System Calls in 32-bit Linux CSCE 410/611 ... but they are not! Making System Calls in 32-bit Linux load system call number in register eax. load arguments to system call in registers ebx, exc, edx, esi, edi, ebp invoke software interrupt: int 0x80 Returned values are stored in eax. 64-bit Linux? same but different different registers different numbers syscall instruction System Calls

CSCE 410/611 System Call Numbers syscalls.kernelgrok.com System Calls

System Calls - Example Using the Unix Standard Library

System Calls - Example Using 32-bit Linux System Calls

System Calls - Example Using 64-bit Linux System Calls

System Calls are Expensive! CSCE 410/611 System Calls are Expensive! Software interrupts are expensive! Cost of context switch (saving/restoring registers) Caches are stale TLBs CPU pipelines Compiler optimization not possible. System Calls

Why Interrupts or syscall? CSCE 410/611 Why Interrupts or syscall? Reason 1: Can load user program into memory without knowing exact address of system functions. Reason 2: Separation of address space, including stacks: user stack and kernel stack. Reason 3: Automatic change to supervisor mode. Reason 4: Can control access to kernel by masking interrupts. System Calls

Reason 4: Mutual Exclusion in Kernel CSCE 410/611 Reason 4: Mutual Exclusion in Kernel user space Thread 2 Thread 1 Thread 1 Thread 1 interrupt! system call kernel space Thread 1 executing in kernel. Interrupts are masked. Thread 2 can not enter kernel because of masked interrupts unmasks interrupt and returns rti System Calls

Summary: System Calls System calls are the OS API CSCE 410/611 System calls are the OS API They look like function calls... ... but they are not! They are implemented using software interrupts (or variations thereof) Why are they implemented this way? System Calls