Chapter 1 : Linux System Programs FAQs
Expert Level 1 : Introduction
Components of linux system
System calls
Expert Level 2 : File management
File I/O system calls
Synchrone File I/O: sync(), fsync(), fdatasync()
Positional Reads and Writes: pread(), pwrite()
Truncating files: truncate(), ftruncate()
Multiplexed I/O: select(), poll()
Program to open existing file for reading
Program to create an empty file for writing using open system call
Program to read 10 bytes from an existing non empty file
Program to read all the bytes from an existing non empty file
Program to create an empty file for writing using creat system call
Program to write a string into an empty file
Program to append a string into existing file
Program to show the usecase of sync()
Program to show use case of fsync()
Program to show use case of fdatasync()
Program to read nth byte of a file and copy it to another file using lseek
Program to write a string into a file using pwrite and read the file using pread
Program to truncate a file
Expert Level 3 : Process Management
Signals
signals: signal system call
signals: sigaction system call
signals: kill system call
signals: raise system call
signals: pause system call
signals: alarm system call
Mapping signal Numbers to Strings: psignal(), strsignal()
signals: killpg system call
Process
Different process states
Process: fork system call
Process: exec system call
Process: exit system call
Process: abort system call
Process: assert system call
Process: wait, waitpid system call
Process: getpid, getppid
Threads
Posix threads
pthread: pthread_create
pthread: pthread_exit
pthread: pthread_join
pthread: pthread_self
pthread: pthread_equal
pthread: pthread_cancel
pthread: pthread_detach
system calls to get, set time
sleep, usleep, nanosleep system calls
Interval timers
Posix timer: timer_create
Posix timer: timer_settime, timer_gettime
Posix_timer: timer_getoverrun
Posix timer: timer_delete
Program to print a string infinite times and terminate if user press ctrl+c
Program to illustrate user-defined Signal Handler
Program to setup a simple signal handler using sigaction
Program to register a signal handler for SIGINT that simply prints a message and then terminates the program (Use pause())
Program to map signal numbres to string using sys_siglist
Program to send SIGUSR1 to current process using raise ssysytem call
Program which traps all the signals (that can be trapped) and displays a suitable message when any signal is received by the process.
Program which reads and displays characters typed at the keyboard. Set up an alarm which will print a message if no characters are typed within a short space of time.
Program to send SIGKILL signals to all of your running processes except your current process
Program to register the same handler for SIGTERM and SIGINT, reset the behavior for SIGPROF to the default and ignore SIGHUP.
Program to create a child process and print whether the process is child or parent.
Program to create a child process and print pid of parent and child process.
Program to print current time of the day
Expert Level 4 : System V IPC
IPC mechanism
Pipes and FIFOs
Pipe: pipe system call
Pipe: popen, pclose
FiFO: mkfifo
IPC mechanism: system V message queues
IPC mechanism: shared memory
Expert Level 5 : System V Synchronization
Expert Level 6 : POSIX IPC
Posix message queues
Posix message queue: mq_open
Posix message queue: mq_close
Posix message queue: mq_unlink
Posix message queue: mq_getattr, mq_setattr
Posix message queue: mq_send
Posix message queue: mq_receive
Posix message queue: mq_notify
Posix shared memory
Expert Level 7 : POSIX Synchronization
Expert Level 8 : Networking
- Implement a TCP IPv4 server and client to exchange continuous data; A chat box.
socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- Implement a UDP IPv4 server and client to exchange continuous data; A chat box.
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- Implement a TCP IPv6 server and client to exchange continuous data; A chat box.
socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
- Implement a UDP IPv6 server and client to exchange continuous data; A chat box.
socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
- Implement a Raw TCP IPv4 server and client to exchange continuous data; A chat box.
socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
- Implement a Raw UDP IPv4 server and client to exchange continuous data; A chat box.
socket(PF_INET, SOCK_RAW, IPPROTO_UDP);
- Implement a Raw TCP IPv6 server and client to exchange continuous data; A chat box.
socket(AF_INET6, SOCK_RAW, IPPROTO_TCP);
- Implement a Raw UDP IPv6 server and client to exchange continuous data; A chat box.
socket(AF_INET6, SOCK_RAW, IPPROTO_UDP);