Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection.

Slides:



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

Chap 2 System Structures.
Operating System Structure
Unix-v5 Process Structure
Operating-System Structures
UNIX File Systems (Chap 4. in the book “the design of the UNIX OS”) Acknowledgement : Soongsil Univ. Presentation Materials.
File System – Unix baed. An entry of Active File table: 1. Access Right: r/w/x 2. Process Count: no. of processes which are now referring to the file.
CS 311 – Lecture 09 Outline Introduction to Systems programming – System calls – Categories of system calls Error Management System calls File Handling.
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
Introduction to Kernel
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Chapter 4. INTERNAL REPRESENTATION OF FILES
File System Review bottomupcs.com J. Kubiatowicz, UC Berkeley.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
10/23/ File System Architecture. 10/23/ / bin unixdev etc user jim mike x y z tty00 tty01 File System architecture.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
Operating-System Structures. Operating System Services Operating systems provide an environment for execution of programs and services to programs and.
UNIX Files File organization and a few primitives.
Chapter 4. INTERNAL REPRESENTATION OF FILES
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Project 6 Unix File System. Administrative No Design Review – A design document instead 2-3 pages max No collaboration with peers – Piazza is for clarifications.
Silberschatz, Galvin and Gagne  Operating System Concepts UNIT II Operating System Services.
System Administration – Part 2. Devices in UNIX are files: A device can be accessed with different file names All device files are stored in /dev or its.
1 Chapter 4. INTERNAL REPRESENTATION OF FILES THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall.
Linux File system Implementations
Laface 2007 File system 2.1 Operating System Design Filesystem system calls buffer allocation algorithms getblk brelse bread breada bwrite iget iput bmap.
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Lecture 19 Linux/Unix – File System
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM.
4P13 Week 9 Talking Points
Chapter 1 Introduction  What is an operating system  History of operating systems  The operating system zoo  Computer hardware review  Operating system.
1 The File System. 2 Linux File System Linux supports 15 file systems –ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs,
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
System Components Operating System Services System Calls.
Introduction to Kernel
Chapter 2: Operating-System Structures
Avani R.Vasant V.V.P. Engineering College
Protection of System Resources
Lecture 4: Operating System Structures
Chapter 2: System Structures
CS 3305 System Calls Lecture 7.
Chapter 4: System calls for the file system
ThreadOS: File System Implementation
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S
An overview of the kernel structure
Chapter 2: Operating-System Structures
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Chapter 1 Introduction to Operating System Part 5
Advanced UNIX progamming
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Chapter 2: Operating-System Structures
UNIX File Systems (Chap 4. in the book “the design of the UNIX OS”)
System Calls System calls are the user API to the OS
Chapter 2: Operating-System Structures
Internal Representation of Files
Structure of Processes
Mr. M. D. Jamadar Assistant Professor
Presentation transcript:

Operating system services Program execution I/O operations File-system manipulation Communications Error detection Resource allocation Accounting Protection

System Calls Provide an interface between a process and the operating system. Generally available as assembly-language instructions UNIX system calls maybe invoked directly from a C or C++ program System calls for modern Microsoft Windows platforms are part of the Win32 application programmer interface (API), which is available for use by all the compilers written for Microsoft Windows

Example of how system calls are used… Consider writing a simple program to read data from one file and to copy them to another file What is the first thing the program needs? Which would be the process? Details in the lecture…

Passing parameters to the operating system The simplest approach is to pass parameters in registers. In some cases, there may be more parameters than registers. In these cases, the parameters are generally stored in a block or table in memory, and the address of the block is passed as a parameter ina register. This is the approach taken by LINUX. Parameters can also be placed, or pushed onto a stack by the program, and popped off the stack by the operating system. Some operating systems prefer the stack or block method, because they do not limit the number or length of parameters being passed.

Groups of system calls Process control –End, abort –Load, execute –Create process, terminate –Get, set attributes –Wait for time –Wait event, signal event –Allocate free memory File management –Create, delete file –Open, close –Read, write, reposition –Get, set file attributes Device management –Request, release device –Read, write –Get, set device attributes –Logically attch, detach devices Information maintenance –Get, set time/date –Get, set system data –Get, set process, file or device attribute Communications –Create, delete communciation connection –Send, receive messages –Transfer status information –Attach or detach remote devices

SYSTEM CALLS FOR THE FILE SYSTEM Return File Desc Use of nameiAssign inodes File Attributes File I/OFile Sys Structure Tree Manipulation open creat dup pipe close open stat creat link chdir unlink chroot mknod chown mount chmod mount creat mknod link unlink chown chmod stat read write lseek mount umount chdir chown

System Calls System calls that return file descriptors for use in other system calls System calls that use the namei algorithm to parse a path name System calls that assign and free inodes, using algorithms ialloc and ifree System calls that set or change the attributes of a file System calls that do I/O to and from a process, using algorithms alloc, free and the buffer application algorithms System calls that change the structure of the file system System calls that allow a process to change its view of the fiel system tree

OPEN The open system call is the first step a process must take to access the file open(pathname,flags,modes) Algorithm open Inputs: file name, type of open, file permissions (for creation type of open) Output: file descriptor { convert file name to inode (algorithm namei); if (file does not exist or not permitted access) return (error); allocate the file table entry for inode, initialise count, offset; allocate user file descriptor entry, set pointer to file table entry; if (type of open specifies truncate file) free all file blocks (algorithm free); unlock (inode); /*locked above in namei */ return (user file descriptor); }

Data structures after OPEN …………… …………… User file descriptor table inode tablefile table Count 1 Read Count 1 Rd-Wrt Count 1 Write Count 2 (/etc/passwd) Count 1 (local)

Data structures after two processes OPEN …………… …………… User file descriptor table (proc A) inode tablefile table Count 1 Read Count 1 Rd-Wrt Count 1 Write Count 2 (/etc/passwd) Count 1 (local) …………… …………… User file descriptor table (proc B) Count 1 Read Count 1 (private)

READ read (fd,buffer,count) algorithm read inputs: user file descriptor, address of buffer in user process, number of bytes to read output: count of bytes copied into user space { get file table entry from user file descriptor; check file accessibility; set parameters in u area for user address, byte count, I/O to user; get inode from file table; lock inode; set byte offset in u area from file table offset; while (count not satisfied) { convert file offset to disk block (algorithm bmap); calculate offset into block, number of bytes to read; if (number of bytes to read is 0) break; read block (algorithm breada if with read ahead, algorithm bread otherwise); copy data from system buffer to user address; update u area fields for file byte offset, read count, address to write into user space; release buffer; } unlock inode; update file table offset for next read; return (total number of bytes read); }

WRITE write (fd,buffer,count) Reading a file via two descriptors: #include main() { int fd1, fd2; char buf1[512], buf2[512]; fd1 = open(“/etc/passwrd”, O_RD); fd2 = open(“/etc/passwrd”, O_RD); read(fd1,buf1,sizeof(buf1)); read(fd2,buf2,sizeof(buf2)); }

Tables after CLOSING a file …………… …………… User file descriptors inode tablefile table Count 1 Count 2 (/etc/passwd) Count 1 (local) …………… …………… Count 1 Count 1 (private)

FILE CREATION algorithm creat input: file name, permission settings output: file descriptor {get inode for file name (algorithm namei); if (file already exists) { if (not permitted access) { release inode (algorithm iput); return (error); } } else/*file does not exist yet */ {assign free inode from file system (algorithm ialloc); create new directory entry in parent directory; include new file name and newly assigned inode number; } allocate file table entry for inode, initialise count; if (file did exist at time of create) free all file blocks (algorithm free); unlock (inode); return (user file descriptor); }

chdir, chroot chdir(pathname) chroot(pathname) chown(pathname, owner, group) chmod(pathname, mode)

PIPES Pipes allow transfer of data between processes in a FIFO manner. Named & unnamed pipes Pipe System call: pipe(fdptr) Opening a named pipe Reading and writing pipes Closing pipes

MOUNT - UNMOUNT The mount system call connects the file system in a specified section of a disk to the existing file system hierarchy The unmount system disconnects a file system from the hierarchy mount(special pathname, directory pathname, options) unmount(special pathname)

File System tree before and after Mount / bin etcusr ccdateshgettypasswd / bin includesrc awkbanneryaccstdio.h uts Root file system /dev/dsk1 file system

LINK - UNLINK The link system call links a file to a new name in the file system directory structure, creating a new directory entry for an exitsing node link(source file name, target file name) The unlink system call removes a directory entry for a file unlink(pathname)

FILE SYSTEM MAINTENANCE The kernel maintains consistency of the file system during normal operation. The command fsck checks for consistency and repairs the file system in case of extraordinary circumstances (power failure)