Page 440 - DCAP103_Principle of operating system
P. 440
Unit 14: Case Study of Linux Operating System
outweighs reliability (e.g., for multimedia delivery, in which being fast counts for more than Notes
being right). When a socket is created, one of the parameters specifies the protocol to be used for
it. For reliable byte streams, the most popular protocol is TCP (Transmission Control Protocol).
For unreliable packet-oriented transmission, UDP (User Datagram Protocol) is the usual choice.
Both are these are layered on top of IP (Internet Protocol). All of these protocols originated
with the U.S. Dept. of Defense’s ARPANET, and now form the basis of the Internet. There is
no common protocol for reliable packet streams. Before a socket can be used for networking, it
must have an address bound to it. This address can be in one of several naming domains. The
most common domain is the Internet naming domain, which uses 32-bit integers for naming
endpoints in Version 4 and 128-bit integers in Version 6 (Version 5 was an experimental system
that never made it to the major leagues).
Once sockets have been created on both the source and destination computers, a connection can be
established between them (for connection-oriented communication). One party makes a listen system
call on a local socket, which creates a buffer and blocks until data arrive. The other one makes a
connect system call, giving as parameters the file descriptor for a local socket and the address
of a remote socket. If the remote party accepts the call, the system then establishes a connection
between the sockets. Once a connection has been established, it functions analogously to a
pipe. A process can read and write from it using the file descriptor for its local socket. When
the connection is no longer needed, it can be closed in the usual way, via the close system call.
14.5.3 Input/Output System Calls in Linux
Each I/O device in a Linux system generally has a special file associated with it. Most I/O can
be done by just using the proper file, eliminating the need for special system calls. Nevertheless,
sometimes there is a need for something that is device specific. Prior to POSIX most UNIX
systems had a system call ioctl that performed a large number of device-specific actions on
special files. Over the course of the years, it had gotten to be quite a mess. POSIX cleaned it up
by splitting its functions into separate function calls primarily for terminal devices. In Linux,
and modern UNIX systems in general, whether each one is a separate system call or they share
a single system call or something else is implementation dependent.
The first four listed in Figure 14.20 are used to set and get the terminal speed. Different calls are
provided for input and output because some modems operate at split speed. For example, old
videotex systems allowed people to access public databases with short requests from the home
to the server at 75 bits/sec with replies coming back at 1200 bits/sec. This standard was adopted
at a time when 1200 bits/sec both ways was too expensive for home use. Time has changed in
the networking world. This asymmetry still persists, with some telephone companies offering
inbound service at 8 Mbps and outbound service at 512 Kbps, often under the name of ADSL
(Asymmetric Digital Subscriber Line).
Figure 14.20: The Main POSIX Calls for Managing the Terminal
Function call Description
s = cfsetospeed(& termios, speed) Set the output speed
s = cfsetispeed(&termios, speed) Set the input speed
s = cfgetospeed(& termios, speed) Get the output speed
s = cfgtetispeed(&termios, speed) Get the input speed
s = tcsetattr(fd, opt, & termios) Set the attributes
s = tcgetattr(fd, & termios) Get the attributes
LOVELY PROFESSIONAL UNIVERSITY 433