Professional Documents
Culture Documents
UNIX - Miscelleneous Topics
UNIX - Miscelleneous Topics
Miscelleneou
s Topics
SEM VI MBAT CS
Contents
•Standard I/O Library
•Daemon processes
• When we open or create a file with the standard I/O library, we say that we have
associated a stream with the file. ( This stream is different than the XSI STREAMS)
•Three streams are predefined and automatically available to a process: standard input,
standard output, and standard error. These streams refer to the same files as the file
descriptors STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO, respectively.
•These three standard I/O streams are referenced through the predefined file pointers
stdin, stdout, and stderr. The file pointers are defined in the <stdio.h> header.
Standard I/O Library (Contd.)
•Standard I/O library allows buffering.
◦ Fully Buffered : Associated functions malloc and flush. Actual I/O takes place when the standard
I/O buffer is filled. Files residing on disk are normally fully buffered by the standard I/O library.
• Line Buffered. The buffer size is fixed. the standard I/O library performs I/O when a newline
character is encountered on input or output. This allows us to output a single character at a time
(with the standard I/O fputc function), knowing that actual I/O will take place only when we finish
writing each line. Line buffering is typically used on a stream when it refers to a terminal—standard
input and standard output, for example.
• Unbuffered. The standard I/O library does not buffer the characters. If we write 15 characters with
the standard I/O fputs function, for example, we expect these 15 characters to be output as soon as
possible. The standard error stream, for example, is normally unbuffered so that any error
messages are displayed as quickly as possible, regardless of whether they contain a newline.
Standard I/O Library (Contd.)
• The fopen, freopen, and fdopen functions open a standard I/O stream.
Standard I/O Library (Contd.)
1. Character-at-a-time I/O. We can read or write one character at a time, with the standard I/O functions
handling all the buffering, if the stream is buffered.
2. Line-at-a-time I/O. If we want to read or write a line at a time, we use fgets and fputs. Each line is
terminated with a newline character, and we have to specify the maximum line length that we can handle
when we call fgets.
3. Direct I/O. This type of I/O is supported by the fread and fwrite functions. For each I/O operation, we
read or write some number of objects, where each object is of a specified size. These two functions are often
used for binary files where we read or write a structure with each operation.
Standard I/O Library (Contd.)
Positioning a stream
Standard I/O Library (Contd.)
Formatted I/O.
kswapd daemon supports the virtual memory subsystem by writing dirty pages to disk slowly over time, so the pages can
be reclaimed.
flush daemon flushes dirty pages to disk when available memory reaches a configured minimum threshold. It also flushes
dirty pages back to disk at regular intervals to decrease data loss in the event of a system failure.
The rpcbind daemon provides the service of mapping RPC (Remote Procedure Call) program numbers to network port
numbers.
The rsyslogd daemon is available to any program to log system messages for an administrator.
inetd daemon listens on the system’s network interfaces for incoming requests for various
network servers.
The nfsd, nfsiod, lockd, rpciod, rpc.idmapd, rpc.statd, and rpc.mountd daemons provide support
for the Network File System (NFS).
The cron daemon executes commands at regularly scheduled dates and times.
Disk Utility
Checking Hard Disk Usage
To maintain adequate hard disk free space, these
strategies are used:
◦ Be vigilant against running dangerously low on
free space by using the df command
◦ Watch for conspicuous consumption using the
du command
◦ Follow a routine schedule for “garbage”
collection and removal by using the find and rm
commands
The du utility
summarizes disk
usage, expressed in
512-byte blocks
(default) or by the
number of bytes
(-b option)