Input and Output System Calls
|
|
- Daisy Golden
- 6 years ago
- Views:
Transcription
1 Chapter 2 Input and Output System Calls Internal UNIX System Calls & Libraries Using C OBJECTIVES Upon completion of this unit, you will be able to: Describe the characteristics of a file Open and close a file Read and write data to and from a file Change the read/write position in a file Control a file Chapter 2-1 Chapter 2-1
2 WHAT IS A FILE? z A file is a contiguous sequence of bytes. z No format imposed by the operating system z Each byte is individually addressable in a disk file. z Automatic expansion as data is written to a disk file z End-of-file indication is not part of data. z A file is also a uniform interface to external devices. Chapter 2-2 OPENING A FILE open(2) NAME SYNOPSIS open --- open for reading or writing #include <fcntl.h> int open (path, oflag [, mode ] ) char *path; int oflag, mode; RETURN VALUE success --- nonnegative file descriptor failure is returned and errno is set Chapter 2-3 Chapter 2-2
3 open(2) FLAGS O_RDONLY --- reading only O_WRONLY --- writing only O_RDWR --- reading and writing O_NDELAY --- non-blocking O_APPEND --- positions at the end for all writes O_CREAT --- creates a non-existent file O_TRUNC --- discard all data O_EXCL --- ensure creating non-existent file O_SYNC --- wait for physical write Chapter 2-4 OPENING A FILE --- EXAMPLES z open a file for reading acctfd = open ( account, O_RDONLY) ; z open a file for writing file = TMPFILE ; fd = open ( file, O_WRONLY O_CREAT O_TRUNC, 0600) ; z open a file for appending logfd = open ( /sys/log, O_WRONLY O_APPEND O_CREAT, 0600) ; z open a file for reading and writing fdin = open ( argv[1], O_RDWR) ; z create a new file for writing if ( ( fdout = open ( TMPFILE, O_WRONLY O_CREAT O_EXCL, 0600 ) ) = = -1 ) perror ( TMPFILE ) ; Chapter 2-5 Chapter 2-3
4 FILE TABLES file descriptor table (inside user area) system file table system inode table Chapter 2-6 CLOSING A FILE close(2) NAME SYNOPSIS close --- close a file descriptor int close ( fildes ) int fildes ; RETURN VALUE success failure and errno is set Chapter 2-7 Chapter 2-4
5 read(2) NAME READ FROM A FILE read --- read from a file SYNOPSIS int read ( fildes, buf, nbyte ) int fildes ; char *buf ; unsigned nbytes ; RETURN VALUE success --- the number of bytes read failure and errno is set Chapter 2-8 write(2) NAME WRITE TO A FILE write --- write to file SYNOPSIS int write ( fildes, buf, nbyte ) int fildes ; char *buf ; unsigned nbyte ; RETURN VALUE success --- the number of bytes written. failure and errno is set Chapter 2-9 Chapter 2-5
6 COPY INPUT TO OUTPUT --- EXAMPLE 1 #include <stdio.h> 2 3 main( ) 4 { 5 char buf [ BUFSIZ ] ; 6 int n ; 7 8 while ( ( n = read ( 0, buf, BUFSIZ ) ) > 0 ) 9 write ( 1, buf, n ) ; 10 exit ( 0 ) ; 11 } Chapter 2-10 COPY FILE --- EXAMPLE 1 #include <stdio.h> 2 #include <fcntl.h> 3 #define PMODE main ( argc, argv ) 6 int argc ; 7 char *argv [ ] ; 8 { 9 int fdin, fdout, n ; 10 char buf [ BUFSIZ ] ; if ( argc!= 3 ) { 13 fprintf ( stderr, Usage : %s filein fileout \n, 14 argv [0] ) ; 15 exit (1) ; 16 } Chapter 2-11 Chapter 2-6
7 17 if ( ( fdin = open ( argv [1], O_RDONLY ) ) = = -1 ) { 18 perror ( argv [1] ) ; 19 exit (2) ; 20 } 21 if ( ( fdout = open ( argv [2], O_WRONLY O_CREAT 22 O_TRUNC, PMODE ) ) = = -1 ) { 23 perror ( argv [2] ) ; 24 exit (3) ; 25 } while ( ( n = read ( fdin, buf, BUFSIZ ) ) > 0 ) 28 write ( fdout, buf, n ) ; exit (0) ; 31 } Chapter 2-12 MOVE READ/WRITE FILE POSITION lseek(2) NAME failure --- lseek --- move read/write file position SYNOPSIS long lseek ( fildes, offset, whence ) int fildes ; long offset ; int whence; RETURN VALUE success --- location in bytes from beginning of the file -1 and errno is set Chapter 2-13 Chapter 2-7
8 lseek(2) --- EXAMPLE z rewind z append lseek ( fd, 0L, 0 ) ; lseek ( fd, 0L, 2 ) ; z update read ( fd, (char *) &record, sizeof (record) ) ; /* update */ lseek ( fd, (long) -sizeof (record), 1 ) ; write ( fd, (char *) &record, sizeof (record) ) ; z record position loc = lseek ( fd, 0L, 1 ) ; z increase file lseek ( fd, (long) MAX * sizeof (record), 2 ) ; write ( fd, (char *) &record, sizeof (record) ) ; Chapter 2-14 CREATING AN EMPLOYEE FILE --- EXAMPLE 1 #include <fcntl.h> 2 #include <stdio.h> 3 #include employee.h 4 5 main ( argc, argv ) /* create employee file */ 6 int argc ; 7 char *argv [ ] ; 8 { 9 int fd, open ( ), getpid ( ) ; 10 struct employee record ; if ( argc < 2 ) { 13 fprintf ( stderr, Usage : %s file\n, argv [0] ) ; 14 exit (1); 15 } Chapter 2-15 Chapter 2-8
9 16 if ( ( fd = open ( argv [1], O_WRONLY O_CREAT 17 O_EXCL, 0640 ) ) = = -1 ) { 18 perror ( argv [1] ) ; 19 exit (2) ; 20 } 21 for ( ; ; ) { 22 printf ( Enter employee name <SPACE> salary : ); 23 scanf ( %s, record.name ) ; 24 if ( record.name [0] = =. ) 25 break ; 26 scanf ( %d, &record.salary ) ; 27 record.pid = getpid ( ) ; 28 write ( fd, (char *) &record, sizeof ( record ) ) ; 29 } 30 close ( fd ) ; 31 exit (0) ; 32 } Chapter 2-16 QUERYING THE EMPLOYEE FILE --- EXAMPLE 1 #include <fcntl.h> 2 #include employee.h 3 4 main ( argc, argv ) 5 int argc ; 6 char *argv [ ] ; 7 { 8 int fd, recnum ; 9 struct employee record ; if ( ( fd = open ( argv [1], O_RDONLY ) ) = = -1 ) { 12 perror ( argv [1] ) ; 13 exit (2); 14 } Chapter 2-17 Chapter 2-9
10 15 for ( ; ; ) { 16 printf ( \n Enter record number : ) ; 17 scanf ( %d, &recnum ) ; 18 if ( recnum < 0 ) 19 break ; 20 lseek ( fd, (long) recnum*sizeof ( record ), 0 ) ; 21 if ( read ( fd, (char *) &record, 22 sizeof ( record ) ) > 0 ) 23 printf ( Employee : %s \t Salary : %d \n, 24 record.name, record.salary ) ; 25 else 26 printf ( Record %d not found \n, recnum ) ; 27 } 28 close ( fd ) ; 29 exit (0) ; 30 } Chapter 2-18 DUPLICATE A FILE DESCRIPTOR dup(2) NAME SYNOPSIS dup --- duplicate an open file descriptor int dup ( fildes ) int fildes ; RETURN VALUE success --- a nonnegative file descriptor is returned failure is returned and errno is set Chapter 2-19 Chapter 2-10
11 dup(2) --- FILE TABLES file descriptor table system file table system inode table Chapter 2-20 INPUT/OUTPUT REDIRECTION --- EXAMPLE 1 #include <fcntl.h> 2 #include <stdio.h> 3 4 main ( argc, argv ) /* demonstrate dup (2) */ 5 int argc ; 6 char *argv [ ] ; 7 { 8 9 close (1); 10 if ( open (argv [1], O_WRONLY 11 O_CREAT O_TRUNC, 0644 ) = = -1 ) { 12 perror ( argv [1] ) ; 13 exit (1) ; 14 } 15 Chapter 2-21 Chapter 2-11
12 16 close (2) ; 17 if ( dup (1) = = -1 ) { 18 perror ( argv [0] ) ; 19 exit (2) ; 20 } printf ( first line to stdout ( uses fd 1 ) \n ) ; 23 fprintf ( stderr, first line to srderr ( uses fd 2 ) \n ) ; 24 printf ( second line to stdout \n ) ; 25 fprintf ( stderr, second line to stderr \n ) ; } Chapter 2-22 FILE CONTROL fcntl(2) NAME fcntl --- file control SYNOPSIS #include <fcntl.h> int fcntl ( fildes, cmd, arg ) int fildes, cmd ; int arg ; or struct flock *arg ; RETURN VALUE success --- depends on cmd failure and errno is set Chapter 2-23 Chapter 2-12
13 fcntl(2) COMMANDS z int arg ; F_DUPFD --- duplicate a file descriptor F_GETFD --- get the close-on-exec flag F_SETFD --- set the close-on-exec flag F_GETFL --- get the file status flags F_SETFL --- set the file status flags Chapter 2-24 ADDING EMPLOYEE RECORDS --- EXAMPLE 1 #include <fcntl.h> 2 #include employee 3 #define DUMMY main ( argc, argv ) 6 int argc ; 7 char *argv [ ] ; 8 { 9 struct employee record ; 10 int fd, open( ), flags, fcntl( ), pid, getpid( ) ; if ( ( fd = open ( argv[1], O_RDWR ) ) = = -1 ) { 13 perror ( argv[1] ) ; 14 exit (1) ; 15 } 16 /* 17 * other data processing here žöof 18 fj jš æbú*/ Chapter 2-25 Chapter 2-13
14 19 if ( ( flags = fcntl ( fd, F_GETFL, DUMMY ) ) = = -1 ) { 20 perror (argv[1]) ; 21 exit (2) ; 22 } 23 flags!= O_APPEND ; 24 fcntl ( fd, F_SETFL, flags ) ; 25 pid = getpid( ) ; 26 for ( ; ; ) { 27 printf ( /nenter employee name : ) ; 28 scanf ( %s, record.name) ; 29 if ( record.name[0] = =. ) 30 break ; 31 printf ( Enter employee salary : ) ; 32 scanf ( %d, &record.salary) ; 33 record.pid = pid ; 34 write ( fd, (char *) &record, sizeof (record) ) ; 35 } 36 close (fd) ; 37 } Chapter 2-26 OPENING TERMINAL FILE --- EXAMPLE O_NDELAY flag 1 #include <stdio.h> 2 #include <fcntl.h> 3 4 main ( ) 5 { 6 int fd, flags, open( ), fcntl( ) ; 7 int i, n ; 8 char line[bufsiz] ; 9 10 if ( ( fd = open ( /dev/tty, O_RDONLY 11 O_NDELAY ) ) = = -1 ) { 12 perror ( /dev/tty ) ; 13 exit (2); 14 } Chapter 2-27 Chapter 2-14
15 15 printf ( Enter your PIN within five seconds : \n> ) ; 16 sleep (5) ; 17 if (read (fd, line, BUFSIZ) = = 0) { 18 printf ( \nsorry\n ) ; 19 exit (1) ; 20 } flags = fcntl ( fd, F_GETFL, 0 ) ; 23 flags &= ~ O_NDELAY ; /* turn off delay flag */ 24 fcntl ( fd, F_SETFL, flags ) ; 25 printf ( Enter your bank account number : \n> ) ; 26 read ( fd, line, BUFSIZ ) ; /* 29 *.... data processing is performed here.. 30 */ 31 } Chapter 2-28 SUMMARY open (2) --- open for reading or writing close (2) --- close a file descriptor read (2) --- read from a file write (2) --- write to file lseek (2) --- move read / write file position fcntl (2) --- file control Chapter 2-29 Chapter 2-15
16 STANDARD INPUT/OUTPUT LIBRARY FUNCTIONS z Functions are easier to use z Functions provide more services z Increases efficiency of programs z Increases portability of programs Chapter 2-30 STANDARD INPUT/OUTPUT INCLUDE FILE < stdio.h >... 2 #ifndef _NFILE 3 #define _NFILE #if u370 6 #define BUFSIZ #endif 8 #if vax u3b u3b5 9 #define BUFSIZ #endif 11 #if pdp11 12 #define BUFSIZ #endif... Chapter 2-31 Chapter 2-16
17 typedef struct { 19 #if vax u3b u3b5 20 int _cnt ; 21 unsigned char *_ptr ; 22 #else 23 unsigned char *_ptr ; 24 int _cnt ; 25 #endif 26 unsigned char *_base ; 27 char _flag ; 28 char _file ; 29 } FILE ; #define getc (p) ( - - (p) -> _cnt < 0? _filbuf (p) : (int) *(p) -> _ptr++ ) 62 #define putc (x, p) ( - - (p) -> _cnt < 0? 63 _flsbuf ( (unsigned char) (x), (p) ) : 64 (int) (*(p) -> _ptr++ = (unsigned char) (x) ) ) extern FILE _iob [ _NFILE ] ; Chapter 2-32 STANDARD I/O PACKAGE Text fpute ( X, fd ) ; Data fp UNI FILE _file = 3 _base = _cnt = 1021 _ptr = BUFSIZ User Area Fd [3] System I/O Cont Chapter 2-33 Chapter 2-17
File I/0. Advanced Programming in the UNIX Environment
File I/0 Advanced Programming in the UNIX Environment File Descriptors Created and managed by the UNIX kernel. Created using open or creat system call. Used to refer to an open file UNIX System shells
More informationOperating System Labs. Yuanbin Wu
Operating System Labs Yuanbin Wu cs@ecnu Annoucement Next Monday (28 Sept): We will have a lecture @ 4-302, 15:00-16:30 DON'T GO TO THE LABORATORY BUILDING! TA email update: ecnucchuang@163.com ecnucchuang@126.com
More informationread(2) There can be several cases where read returns less than the number of bytes requested:
read(2) There can be several cases where read returns less than the number of bytes requested: EOF reached before requested number of bytes have been read Reading from a terminal device, one line read
More informationOutline. Relationship between file descriptors and open files
Outline 3 File I/O 3-1 3.1 File I/O overview 3-3 3.2 open(), read(), write(), and close() 3-7 3.3 The file offset and lseek() 3-21 3.4 Atomicity 3-30 3.5 Relationship between file descriptors and open
More informationI/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo
I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell
More informationUNIX System Programming
File I/O 경희대학교컴퓨터공학과 조진성 UNIX System Programming File in UNIX n Unified interface for all I/Os in UNIX ü Regular(normal) files in file system ü Special files for devices terminal, keyboard, mouse, tape,
More informationI/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo
I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell
More informationSystems Programming. COSC Software Tools. Systems Programming. High-Level vs. Low-Level. High-Level vs. Low-Level.
Systems Programming COSC 2031 - Software Tools Systems Programming (K+R Ch. 7, G+A Ch. 12) The interfaces we use to work with the operating system In this case: Unix Programming at a lower-level Systems
More informationGoals of this Lecture
I/O Management 1 Goals of this Lecture Help you to learn about: The Unix stream concept Standard C I/O functions Unix system-level functions for I/O How the standard C I/O functions use the Unix system-level
More informationChapter 3. File I/O. System Programming 熊博安國立中正大學資訊工程學系
Chapter 3. File I/O System Programming http://www.cs.ccu.edu.tw/~pahsiung/courses/sp 熊博安國立中正大學資訊工程學系 pahsiung@cs.ccu.edu.tw Class: EA-104 (05)2720411 ext. 33119 Office: EA-512 Textbook: Advanced Programming
More informationI/O Management! Goals of this Lecture!
I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix
More informationI/O Management! Goals of this Lecture!
I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix
More informationCSE 410: Systems Programming
CSE 410: Systems Programming Input and Output Ethan Blanton Department of Computer Science and Engineering University at Buffalo I/O Kernel Services We have seen some text I/O using the C Standard Library.
More informationCSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song
CSCE 313 Introduction to Computer Systems Instructor: Dezhen Song UNIX I/O Files and File Representation Basic operations: Reading / Writing Caching: File Open / Close Multiplexing: Select / Poll File
More informationAdvanced Unix/Linux System Program. Instructor: William W.Y. Hsu
Advanced Unix/Linux System Program Instructor: William W.Y. Hsu CONTENTS File I/O, File Sharing 3/15/2018 INTRODUCTION TO COMPETITIVE PROGRAMMING 2 Recall simple-cat.c... /* * Stripped down version of
More informationOperating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line
Operating Systems Lecture 06 System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line March 04, 2013 exec() Typically the exec system call is
More informationwhich maintain a name to inode mapping which is convenient for people to use. All le objects are
UNIX Directory Organization UNIX directories are simple (generally ASCII) les which maain a name to inode mapping which is convenient for people to use. All le objects are represented by one or more names
More informationProcess Management! Goals of this Lecture!
Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" Unix system-level functions for I/O" The Unix stream
More informationCS240: Programming in C
CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor
More informationWhat Is Operating System? Operating Systems, System Calls, and Buffered I/O. Academic Computers in 1983 and Operating System
What Is Operating System? Operating Systems, System Calls, and Buffered I/O emacs gcc Browser DVD Player Operating System CS 217 1 Abstraction of hardware Virtualization Protection and security 2 Academic
More informationHow do we define pointers? Memory allocation. Syntax. Notes. Pointers to variables. Pointers to structures. Pointers to functions. Notes.
, 1 / 33, Summer 2010 Department of Computer Science and Engineering York University Toronto June 15, 2010 Table of contents, 2 / 33 1 2 3 Exam, 4 / 33 You did well Standard input processing Testing Debugging
More informationCSE 333 SECTION 3. POSIX I/O Functions
CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the
More informationUNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT
OPERATING SYSTEM LAB #06 & 07 System Calls In UNIX System Call: A system call is just what its name implies a request for the operating system to do something on behalf of the user s program. Process related
More informationOperating System Labs. Yuanbin Wu
Operating System Labs Yuanbin Wu cs@ecnu Announcement Project 1 due 21:00, Oct. 8 Operating System Labs Introduction of I/O operations Project 1 Sorting Operating System Labs Manipulate I/O System call
More informationUNIX System Calls. Sys Calls versus Library Func
UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the
More informationOutline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra
Outline CSCI 6 Introduction to Operating Systems System I/O and Files File I/O operations File Descriptors and redirection Pipes and FIFOs Instructor: Abhishek Chandra 2 System Input/Output Hardware devices:
More informationHyo-bong Son Computer Systems Laboratory Sungkyunkwan University
File I/O Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O
More informationCSC 271 Software I: Utilities and Internals
CSC 271 Software I: Utilities and Internals Lecture 13 : An Introduction to File I/O in Linux File Descriptors All system calls for I/O operations refer to open files using a file descriptor (a nonnegative
More informationCSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes
CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)
More informationUnix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu
Outline Unix File and I/O (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu Basics of File Systems Directory and Unix File System: inode UNIX I/O System Calls: open, close, read, write, ioctl File Representations:
More informationCSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes
CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)
More informationUNIX input and output
UNIX input and output Disk files In UNIX a disk file is a finite sequence of bytes, usually stored on some nonvolatile medium. Disk files have names, which are called paths. We won t discuss file naming
More informationUNIX System Overview E. Im
UNIX System Overview 2009 E. Im 1 History of UNIX Adopted from Operating System Concepts by Abraham Silberschatz et al. For a full history, refer to http://www.levenez.com/unix General Characteristics
More informationOperating systems. Lecture 7
Operating systems. Lecture 7 Michał Goliński 2018-11-13 Introduction Recall Plan for today History of C/C++ Compiler on the command line Automating builds with make CPU protection rings system calls pointers
More informationRicardo Rocha. Department of Computer Science Faculty of Sciences University of Porto
Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto For more information please consult Advanced Programming in the UNIX Environment, 3rd Edition, W. Richard Stevens and
More informationNaked C Lecture 6. File Operations and System Calls
Naked C Lecture 6 File Operations and System Calls 20 August 2012 Libc and Linking Libc is the standard C library Provides most of the basic functionality that we've been using String functions, fork,
More informationCS 201. Files and I/O. Gerson Robboy Portland State University
CS 201 Files and I/O Gerson Robboy Portland State University A Typical Hardware System CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory USB controller graphics adapter
More informationCS 25200: Systems Programming. Lecture 14: Files, Fork, and Pipes
CS 25200: Systems Programming Lecture 14: Files, Fork, and Pipes Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 14 File table and descriptors Fork and exec Fd manipulation Pipes 2018 Dr. Jeffrey
More informationFile Descriptors and Piping
File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors
More informationPreview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call
Preview File Descriptors for a Process for Managing Files write read open close lseek A system call is a request for the operating system to do something on behalf of the user's program. The system calls
More informationLecture files in /home/hwang/cs375/lecture05 on csserver.
Lecture 5 Lecture files in /home/hwang/cs375/lecture05 on csserver. cp -r /home/hwang/cs375/lecture05. scp -r user@csserver.evansville.edu:/home/hwang/cs375/lecture05. Project 1 posted, due next Thursday
More informationThe course that gives CMU its Zip! I/O Nov 15, 2001
15-213 The course that gives CMU its Zip! I/O Nov 15, 2001 Topics Files Unix I/O Standard I/O A typical hardware system CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory
More informationCSE 333 SECTION 3. POSIX I/O Functions
CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX
More informationUNIX I/O. Computer Systems: A Programmer's Perspective, Randal E. Bryant and David R. O'Hallaron Prentice Hall, 3 rd edition, 2016, Chapter 10
Reference: Advanced Programming in the UNIX Environment, Third Edition, W. Richard Stevens and Stephen A. Rago, Addison-Wesley Professional Computing Series, 2013. Chapter 3 Computer Systems: A Programmer's
More informationCSci 4061 Introduction to Operating Systems. Input/Output: High-level
CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device
More informationAll the scoring jobs will be done by script
File I/O Prof. Jinkyu Jeong( jinkyu@skku.edu) TA-Seokha Shin(seokha.shin@csl.skku.edu) TA-Jinhong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu
More informationData and File Structures Chapter 2. Basic File Processing Operations
Data and File Structures Chapter 2 Basic File Processing Operations 1 Outline Physical versus Logical Files Opening and Closing Files Reading, Writing and Seeking Special Characters in Files The Unix Directory
More informationProgrammation Systèmes Cours 8 Synchronization & File Locking
Programmation Systèmes Cours 8 Synchronization & File Locking Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot 2012 2013 URL http://upsilon.cc/zack/teaching/1213/progsyst/
More informationPhysical Files and Logical Files. Opening Files. Chap 2. Fundamental File Processing Operations. File Structures. Physical file.
File Structures Physical Files and Logical Files Chap 2. Fundamental File Processing Operations Things you have to learn Physical files and logical files File processing operations: create, open, close,
More informationCMPS 105 Systems Programming. Prof. Darrell Long E2.371
+ CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared
More informationChapter 10. The UNIX System Interface
프로그래밍 1 1 Chapter 10. The UNIX System Interface June, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 파일의개념 (1/5) 2 파일의정의 사용자가이용할수있는데이터의실체레코드들의집합이라고정의 파일의필요성 데이터의효율적인저장및검색을위해파일단위구분
More informationNetwork Socket Programming - 1 BUPT/QMUL
Network Socket Programming - 1 BUPT/QMUL 2017-03-13 Review Basic network definitions Terms for Network Devices Terms for Network Performance Parameters Ways to connect to the Internet Terms for Network
More informationCS 33. Shells and Files. CS33 Intro to Computer Systems XX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Shells and Files CS33 Intro to Computer Systems XX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Shells Command and scripting languages for Unix First shell: Thompson shell sh, developed
More informationFiles and Directories
Files and Directories Administrative * HW# 1 Due this week Goals: Understand the file system concepts * files, links, and directories * device independent interface Topics: * 3.0 Device independence *
More informationPrinceton University Computer Science 217: Introduction to Programming Systems. I/O Management
Princeton University Computer Science 7: Introduction to Programming Systems I/O Management Goals of this Lecture Help you to learn about: The C/Unix file abstraction Standard C I/O Data structures & functions
More informationPrinceton University. Computer Science 217: Introduction to Programming Systems. I/O Management
Princeton University Computer Science 7: Introduction to Programming Systems I/O Management Goals of this Lecture Help you to learn about: The C/Unix file abstraction Standard C I/O Data structures & functions
More informationPrinceton University Computer Science 217: Introduction to Programming Systems I/O Management
Princeton University Computer Science 7: Introduction to Programming Systems I/O Management From a student's readme: ====================== Stress Testing ====================== To stress out this program,
More informationSummer June 15, 2010
Summer 2010 Department of omputer Science and Engineering York University Toronto June 15, 2010 1 / 33 Table of contents 1 2 3 2 / 33 Plan 1 2 3 3 / 33 Exam summary You did well Standard input processing
More informationCSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes
CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Today Directory wrap-up Communication/IPC Test in one week Communication Abstraction: conduit for data exchange between two or more processes
More informationSystems Programming. 08. Standard I/O Library. Alexander Holupirek
Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:
More informationPRACTICAL NO : 1. AIM: To study various file management system calls in UNIX.
PRACTICAL NO : 1 AIM: To study various file management system calls in UNIX. Write a program to implement 1. Create a file 2. Delete a file 3. Link a file 4. Copy one file to another file 5. Read contents
More informationAll the scoring jobs will be done by script
File I/O Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) All the scoring jobs
More informationLecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls
Lecture 3 Introduction to Unix Systems Programming: Unix File I/O System Calls 1 Unix File I/O 2 Unix System Calls System calls are low level functions the operating system makes available to applications
More informationUNIX System Programming. Overview. 1. A UNIX System. 2. Processes (review) 2.1. Context. Pipes/FIFOs
UNIX System Programming Pipes/FIFOs Overview 1. A UNIX System (review) 2. Processes (review) Objectives Look at UNIX support for interprocess communication (IPC) on a single machine Review processes pipes,
More informationSystem- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron
System- Level I/O Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron 1 Unix I/O and Files UNIX abstracts many things into files (just a series of bytes) All I/O devices are represented
More informationPreview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall
Preview Process Control What is process? Process identifier The fork() System Call File Sharing Race Condition COSC350 System Software, Fall 2015 1 Von Neumann Computer Architecture: An integrated set
More informationFile I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
File I/O Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices
More informationIntroduction. Files. 3. UNIX provides a simple and consistent interface to operating system services and to devices. Directories
Working With Files Introduction Files 1. In UNIX system or UNIX-like system, all input and output are done by reading or writing files, because all peripheral devices, even keyboard and screen are files
More informationOPERATING SYSTEMS: Lesson 2: Operating System Services
OPERATING SYSTEMS: Lesson 2: Operating System Services Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Goals To understand what an operating
More informationRecitation 8: Tshlab + VM
Recitation 8: Tshlab + VM Instructor: TAs 1 Outline Labs Signals IO Virtual Memory 2 TshLab and MallocLab TshLab due Tuesday MallocLab is released immediately after Start early Do the checkpoint first,
More informationSystem Calls and I/O. CS 241 January 27, Copyright : University of Illinois CS 241 Staff 1
System Calls and I/O CS 241 January 27, 2012 Copyright : University of Illinois CS 241 Staff 1 This lecture Goals Get you familiar with necessary basic system & I/O calls to do programming Things covered
More informationCSci 4061 Introduction to Operating Systems. File Systems: Basics
CSci 4061 Introduction to Operating Systems File Systems: Basics File as Abstraction Naming a File creat/open ( path/name, ); Links: files with multiple names Each name is an alias #include
More informationStandard I/O in C, Computer System and programming in C
Standard I/O in C, Contents 1. Preface/Introduction 2. Standardization and Implementation 3. File I/O 4. Standard I/O Library 5. Files and Directories 6. System Data Files and Information 7. Environment
More informationInter-Process Communication
CS 326: Operating Systems Inter-Process Communication Lecture 10 Today s Schedule Shared Memory Pipes 2/28/18 CS 326: Operating Systems 2 Today s Schedule Shared Memory Pipes 2/28/18 CS 326: Operating
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Sciences and Engineering
INTERNAL ASSESSMENT TEST 2 Solutions 1. Explain the working of the waitpid() API with the help of a program. The program needs to take 2 command line arguments: the first argument should be used as the
More informationCPSC 410/611: File Management. What is a File?
CPSC 410/611: What is a file? Elements of file management File organization Directories File allocation Reading: Silberschatz, Chapter 10, 11 What is a File? A file is a collection of data elements, grouped
More informationeverything is a file main.c a.out /dev/sda1 /dev/tty2 /proc/cpuinfo file descriptor int
everything is a file main.c a.out /dev/sda1 /dev/tty2 /proc/cpuinfo file descriptor int #include #include #include int open(const char *path, int flags); flagso_rdonly
More informationLecture 21 Systems Programming in C
Lecture 21 Systems Programming in C A C program can invoke UNIX system calls directly. A system call can be defined as a request to the operating system to do something on behalf of the program. During
More informationCSE 410: Systems Programming
CSE 410: Systems Programming Pipes and Redirection Ethan Blanton Department of Computer Science and Engineering University at Buffalo Interprocess Communication UNIX pipes are a form of interprocess communication
More informationFile I/O - Filesystems from a user s perspective
File I/O - Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz
More informationT4-Input/Output Management
T4-Input/Output Management SO-Grade 2013-2014 Q2 License Aquest document es troba sota una llicència Reconeixement - No comercial - Compartir Igual sota la mateixa llicència 3.0 de Creative Commons. Per
More informationPOSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017
Linux/UNIX IPC Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2017 mtk@man7.org November 2017 Outline 10 POSIX Shared Memory 10-1 10.1 Overview 10-3 10.2 Creating and opening shared memory
More informationSocket programming in C
Socket programming in C Sven Gestegård Robertz September 2017 Abstract A socket is an endpoint of a communication channel or connection, and can be either local or over the network.
More informationOS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2
OS COMPONENTS OVERVIEW OF UNIX FILE I/O CS124 Operating Systems Fall 2017-2018, Lecture 2 2 Operating System Components (1) Common components of operating systems: Users: Want to solve problems by using
More informationInter-process Communication using Pipes
Inter-process Communication using Pipes Dept. of Computer Science & Engineering 1 Pipes A pipe is a one-way communication channel that couples one process to another. Used only between processes that have
More informationCMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O
CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O Sections 8.2-8.5, Bryant and O'Hallaron PROCESS CONTROL (CONT.) CMSC 216 - Wood, Sussman, Herman, Plane 2 Signals
More informationSystem Calls and I/O Appendix. Copyright : University of Illinois CS 241 Staff 1
System Calls and I/O Appendix Copyright : University of Illinois CS 241 Staff 1 More System Calls Directory and File System Management s = mkdir(name, mode) Create a new directory s = rmdir(name) s = link(name,
More informationMMAP AND PIPE. UNIX Programming 2015 Fall by Euiseong Seo
MMAP AND PIPE UNIX Programming 2015 Fall by Euiseong Seo Memory Mapping mmap(2) system call allows mapping of a file into process address space Instead of using read() and write(), just write to memory
More informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1)
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1) Overview The midterm exam will be in class on Monday, March 28, 2016 from 10:00-11:45AM
More informationFile I/O. Preprocessor Macros
Computer Programming File I/O. Preprocessor Macros Marius Minea marius@cs.upt.ro 4 December 2017 Files and streams A file is a data resource on persistent storage (e.g. disk). File contents are typically
More informationProcesses. Non-examples (implemented as one process): Why processes? - emacs text editor - firefox web browser
Processes A process is an instance of a program running Modern OSes run multiple processes simultaneously Very early OSes only ran one process at a time Examples (can all run simultaneously): - emacs text
More informationCS350 Operating Systems
CS350 Operating Systems Instructor: Ali Mashtizadeh IAs: Zhenyu Bai, Michael Honke, Jade Marcoux-Ouellet Instructional Support: Gang Lu University of Waterloo 1 / 32 Outline 1 Administrivia 2 Substance
More informationCS140 Operating Systems
Outline CS140 Operating Systems Instructor: David Mazières CAs: Ashok Cutkosky, Matthew Denton, Brendon Go, Saachi Jain, and Diveesh Singh Stanford University 1 Administrivia 2 Substance 1 / 35 2 / 35
More informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS Overview The final exam will be on Tuesday, May 17, 2016 from
More informationComputer Science & Engineering Department I. I. T. Kharagpur
Computer Science & Engineering Department I. I. T. Kharagpur Operating System: CS33007 3rd Year CSE: 5th Semester (Autumn 2006-2007) Lecture III (Linux System Calls II) Goutam Biswas Date: 1st-7th August,
More informationSOFTWARE ARCHITECTURE 2. FILE SYSTEM. Tatsuya Hagino lecture URL. https://vu5.sfc.keio.ac.jp/sa/login.php
1 SOFTWARE ARCHITECTURE 2. FILE SYSTEM Tatsuya Hagino hagino@sfc.keio.ac.jp lecture URL https://vu5.sfc.keio.ac.jp/sa/login.php 2 Operating System Structure Application Operating System System call processing
More informationWhat did we talk about last time? Selection Loops Lab 3
Week 4 - Monday What did we talk about last time? Selection Loops Lab 3 Unix was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things. Doug Gwyn
More informationFile I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 File I/O Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Unix files 2 A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices are represented
More informationProcesses COMPSCI 386
Processes COMPSCI 386 Elements of a Process A process is a program in execution. Distinct processes may be created from the same program, but they are separate execution sequences. call stack heap STACK
More informationWhat is a Process. Preview. What is a Process. What is a Process. Process Instruction Cycle. Process Instruction Cycle 3/14/2018.
Preview Process Control What is process? Process identifier A key concept in OS is the process Process a program in execution Once a process is created, OS not only reserve space (in Memory) for the process
More information