23-files-io-devices-part1

23-files-io-devices-part1 - CS241 Systems Programming...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
  1 CS241 Systems Programming Files, IO, devices Yoann Padioleau
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
  2 Course status Past lectures: How to use the  CPU process threads , synchronisations  ( mutex semaphore ), timers Next lectures: How to use  devices, disks files filesystem How to use the  memory virtual memory How to use the  network sockets , TCP/IP How to use, why need it, and how it works under the hood
Background image of page 2
  3 Use of files How a process get/produce information, how it communicates with  external world ? Files  ! Without files, you have a pointless program/process manipulating its own  memory, which BTW is isolated from any other process. UNIX:  Everything is a file Use files for files   to store information ( .emacs foo.txt bar.c ) Use  device files  ( /dev/screen /dev/printer ) Use  pseudo files  (pipes, sockets  /tmp/X.0 , network tubes) File structure: the OS view files as  sequences of bytes . The application  is responsible to make sense of it, to have format.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
  4 Table of contents Interface (user side) Files, File Descriptors Special Files, Device Files, Terminal Files as a form of IPC: redirection, pipes Buffered IO, flush Files and concurrency, O_EXCL, lock, test_and_set at file level Others (mkfifo, socket(), select, mmap, non blocking IO, fcntl, ioctl, terminal  control) Implementation (kernel and hardware side) Device properties Asm in/out ports or memory mapped IO, hardware interrupt Device drivers Interrupt, polling, DMA Scheduling, kernel stack, concurrency in kernel Putting it together: tracing read()
Background image of page 4
  5 open() – read() – write() - close(), fd Regular files        fd=open("/tmp/foo.txt", options ); read(fd,buffer,sizeof(buffer)); close(fd); Device files, easy access to hardware fd=open(“/dev/printer”); fd=open(“/dev/webcam”); Already opened for you by the system (set by parent, usually  the shell) fd0 =~  open(“/dev/keyboard”); fd1 =~  open(“/dev/screen”); See later about path, filesystem, about security,
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

23-files-io-devices-part1 - CS241 Systems Programming...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online