Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The lack of comonality at the driver level percolates up to the user command level
Where several commands may accomplish common
CS502 / IT524
OVERVIEW
Streams
Streams are a scheme for improving the modularity of devie drivers and protocols A Stream is a full-duplex connection between a process and da device Streams modules are characterized by welldefined interfaces and by their flexibility for use in combination with other modules The flexibility they offer has strong benefits for network protocols and drivers
CS502 / IT524 OVERVIEW 2
Streams
Stream Head Output Queue Input Queue Inode of Device file
Driver
Output Queue
Input Queue
a queue pair
CS502 / IT524
OVERVIEW
Streams
Message 1 Block
Message 2
Message 3
CS502 / IT524
OVERVIEW
Streams
Stream Head Output Queue Input Queue Inode of Device file
Line Discipline
Output Queue
Input Queue
Terminal Driver
Output Queue
Input Queue
sh1
sh1
mpx
ttyld
ttyld
msg
msg
Pty pair 1
CS502 / IT524
OVERVIEW
/* assume filedescriptors 0 and 1 already refer to physical tty */ For(;;) { select(input); read input line; switch(line with input data) { case physical tty: if ( control command ) { open a free pseude-tty; fork a new process: if(parent) { push a msg discipline on mpx side; continue; } /* child here */ close unnecessary file descriptors; open other member of pseude-tty pair, get stdin, stdout, stderr; push tty line discipline; exec shell; } CS502 / IT524 OVERVIEW 8
/* regular data from tty coming up for virtual tty */ Demultiplex data read from physical tty, strip off headers and write to appropriate pty; Continue; /* back to for loop */ Case logical tty: /* a virtual tty is writing a window */ encode header indicating what window data is for; write header and data to physical tty; continue; } }
CS502 / IT524
OVERVIEW
Summary
Streams are a scheme for improving the modularity of device drivers and protocols. A stream is a full-duplex connection between processes and device drivers, which may contain line disciplines and protocols to process data en route. Streams modules are characterized by well-defined interfaces and by their flexibility for use in combination with other modules.
The flexibility the offer has strong benefits for network protocols and drivers.
CS502 / IT524
OVERVIEW
10