Input - Output.

Slides:



Advertisements
Similar presentations
Secure Operating Systems Lesson 3: OS Structures.
Advertisements

Web siteWeb site ExamplesExamples 1 Mode of Operation Protected mode  4 GB  32-bit address  Windows, Linux Real-address mode  1 MB space  20-bit address.
WinAPI i System Plików 1. Volume Management 2. Disk Management 3. Directory Management 4. File Management Autor: Tomasz Jurkiewicz.
Process Processes are executing or executable instances of programs. Processes in a modern OS haveOS –management information –resources –unique process.
1 JMH Associates © 2004, All rights reserved Chapter 15 Asynchronous Input/Output.
1 JMH Associates © 2004, All rights reserved Chapter 1 Getting Started with Win32/64.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
I/O Systems ◦ Operating Systems ◦ CS550. Note:  Based on Operating Systems Concepts by Silberschatz, Galvin, and Gagne  Strongly recommended to read.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.5. Windows File and Directory.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Windows Network Programming ms-help://MS.MSDNQTR.2004JAN.1033/winsock/winsock/windows_sockets_start_page_2.htm 井民全.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
The Socket Interface Chapter 21. Application Program Interface (API) Interface used between application programs and TCP/IP protocols Interface used between.
FILE HANDLING IN C++.
System Components ● There are three main protected modules of the System  The Hardware Abstraction Layer ● A virtual machine to configure all devices.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS2: Operating System Principles 2.4. The Windows.
Win32 Programming Lesson 17: Memory Mapped Files (Finally, cool stuff again, all this work is getting tedious!)
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
4P13 Week 9 Talking Points
System Programming Course introduction Getting Started …
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
Lecture 20: C File Processing. Why Using Files? Storage of data in variables and arrays is temporary Data lost when a program terminates. Files are used.
Ms N Nashandi Dr SH Nggada 2016/01/03Ms N Nashandi and Dr SH Nggada1 Week 6 -File input and output in C++
Chapter 3 The Programming Interface Chien-Chung Shen CIS/UD
CS212: Object Oriented Analysis and Design
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Astobj2 Joshua Colp, Senior Software Developer 1 1.
Chapter 7 Text Input/Output Objectives
Chapter 7 Text Input/Output Objectives
File Management Mario Tayah and Jim Fawcett
Protection of System Resources
Chapter 7 Text Input/Output Objectives
CS399 New Beginnings Jonathan Walpole.
CSE451 I/O Systems and the Full I/O Path Autumn 2002
Operating System I/O System Monday, August 11, 2008.
Basic Input and Output Operations
File Management.
I/O Manager, 64-bit Porting, and New Driver Models
KERNEL ARCHITECTURE.
This pointer, Dynamic memory allocation, Constructors and Destructor
Files I/O, Streams, I/O Redirection, Reading with fscanf
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S
Windows APIs File Processing Copyright © 2016 Curt Hill.
Interprocess Communication
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Module 2: Computer-System Structures
Files in Windows API David Halbig Lopez.
files Dr. Bhargavi Goswami Department of Computer Science
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Format String.
Architectural Support for OS
Introduction to Operating Systems
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Module 2: Computer-System Structures
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
OPERATING SYSTEMS STRUCTURES
Architectural Support for OS
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
Mario Tayah and Jim Fawcett CSE775 – Distributed Objects Spring 2007
Chapter 13: I/O Systems.
The CreateFile Function
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Input - Output

Files API Files are too managed with the help of handles. When handle is set it is possible to use it in input/output operations That goes for all I/O operations

CreateFile Returns file handle? What about: streams disks communications pipes etc?

lpFileName – file name dwDesiredAccess – generic access rights dwShareMode – sharing mode lpSecurityAttributes – inheritant rights dwCreationDisposition – creation mode dwFlagsAndAttributes – flags and attributes hTemplateFile – template handle

dwDesiredAccess Shows what can be done with file: GENERIC_READ GENERIC_WRITE GENERIC_EXECUTE GENERIC_ALL

dwShareMode Sharing mode of the file or device: 0 – file cannot be shared until handle is closed FILE_SHARE_READ FILE_SHARE_WRITE FILE_SHARE_DELETE

lpSecurityAttributes – saugumo požymis Protects against unwanted access NULL – handle cannot be inherited by child processes Pointer to SECURITY_ATTRIBUTES pointer to SECURITY_DESCRIPTOR recommended not to modify structure directly

dwCreationDisposition Action to take: CREATE_ALWAYS CREATE_NEW OPEN_ALWAYS OPEN_EXISTING TRUNCATE_EXISTING requires GENERIC_WRITE

dwFlagsAndAttributes File or device flags and attributes. Some flags and attributes apply to files only 0 – device is not a file Other most common flags and attributes: FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_HIDDEN FILE_ATTRIBUTE_READONLY FILE_ATTRIBUTE_ARCHIVE

hTemplateFile GENERIC_READ Supplies file attributes for file being created NULL – if not used Ignored when opening existing file

CreateFile2

ReadFile

ReadFileEx

Overlapped I/O Asynchronous I/O Complexity OVERLAPPED structure FileIOCompletionRoutine callback function

WriteFile

WriteFileEx

File attributes (GetFileAttributes) Commonly used attributes: FILE_ATTRIBUTE_ARCHIVE FILE_ATTRIBUTE_HIDDEN FILE_ATTRIBUTE_NORMAL FILE_ATTRIBUTE_READONLY FILE_ATTRIBUTE_SYSTEM

CopyFile lpExistingFileName – name of an existing file lpNewFileName – name of new file bFailIfExists – if TRUE existing file will not be overwritten

CopyFile2

CopyFileEx (1)

CopyFileEx (2) lpProgressRoutine – callback function (CopyProgressRoutine) lpData – argument to be passed to callback function (can be NULL) pbCancel – operation canceled if it is set to TRUE dwCopyFlags – specify, how file is to be copied

CopyProgressRoutine (1)

CopyProgressRoutine (2) TotalFileSize – file size in bytes TotalBytesTransferred – number of bytes already transferred StreamSize – size of current stream in bytes SteramBytesTransferred – number of bytes already transferred from current stream dwStreamNumber – handle to current stream dwCallbackReason – reason this function was called hSourceFile – handle to the source file hDestinationFile – handle to the destination file lpData – data from CopyFileEx function

dwCallbackReason There are two reasons: CALLBACK_CHUNK_FINISHED – part of data was copied CALLBACK_STREAM_SWITCH – another stream created and is about to be copied

CopyProgressRoutine (3) This function returns: PROGRESS_CONTINUE – continue copying PROGRESS_CANCEL – cancel copying and delete destination file PROGRESS_STOP – stop copying (can be restarted later) PROGRES_QUIET – continue copying without invoking callback function

MoveFile[Ex]

DeleteFile & RemoveDirectory

Other features Enumeration Locking Encoding Archiving Memory-mapping etc.

CloseHandle Handles must be closed When program is closing, OS automatically closes all associated handles expensive operation handle leak For sockets – closesocket For registry keys - RegCloseKey

Handle leaks When closing handle fails: Memory isn’t freed Kernel keeps all information about handle Sluggish system Crash