
Explore Linux system programming through hands-on labs, covering file operations, system calls and library functions, GCC compilation, blocking and non-blocking calls, and process management with memory layout and IPC.
Develop proficiency in linux system programming by writing complex c code, understanding linux concepts, collaborating with teams, contributing to projects, and growing into a capable industry leader.
The slides used in this course is added here for your reference.
All programs explained during this course are in C.
GCC compiler is used to compile the code.
command to compile code is
gcc lib_ex.c -o lib_ex
compile the code using below gcc command
gcc sys_ex.c -o sys_ex
Shows how to use the lseek system call to move the file offset for read/write operations, with absolute, relative, and end-of-file seeks, and open, read, write and close.
Tips
Explore race conditions and atomicity in Linux file I/O, driven by multiprocessing and multithreading. Observe log.txt race scenarios under scheduling, blocking vs non blocking I/O, open calls.
Explore atomicity in Linux system calls, where kernel guarantees a single atomic operation from start to finish, returning pass or fail and preventing race around condition in the critical section.
Explore how the Linux kernel uses preemptive scheduling to allocate cpu time slices among processes, contrasting it with non preemptive behavior in kernel mode before version 2.6.
Explore how the file descriptor table links to the open file table and inode, detailing file offsets, flags, and pointers to data blocks, including single, double, and triple indirection.
See how the per-process file descriptor table, the open file table, and the inode table coordinate opening log.txt in read-write mode, with create, seek, and write updating the file offset.
Demonstrate how dup and dup2 duplicate file descriptors, returning newfd, and redirect output to files such as newFile.log and newfile2.log, by illustrating open, unistd.h, and per-process file descriptor tables.
Use case discussion on Race around, Critical section, and Atomic operations
Explore Linux process IDs and parent process IDs by using getpid and getppid, observing how the shell forks child processes, and using ps -ef to reveal pid and ppid relationships.
Summary related to Process
Explore the environment of a process, where environment variables are name-value pairs accessible across functions via environ and get env, with examples of setting new variables.
Demonstrates a lexical exec call where p1 runs p2 by replacing its own process image, preserving the same process id, and passing argv0, argv1, argv2 as arguments.
Explore how the execve system call replaces a running program with another, passing argv and envp, and inspect the new program’s arguments and environment.
Combine fork and exec to create a child process and replace its memory with a new program, while the parent waits and collects the child's exit status.
Note : This course is conducted by IT working Professional, and not by a Professional Instructor.
Q. What is the speciality of this course?
A. This is purely a Course on "Learning Programming using Linux", This course does not teach 'C'. Since this course is conducted by industry working professionals, This course tries to cover gap between academics and Industry, Also the last section Bonus - Students Q & A, contains the collective students questions and its solution to them. It is a regularly updating section.
Q. What is the Prior knowledge required for this course?
A. This course teaches from Basics of Linux Programming to Advanced, hence no prior knowledge on Linux is assumed, but should be energetic to learn Linux technology.
Q. Who is this course for?
A. This course is designed in mind from beginners(students) to intermediate professionals who want to learn Linux and Utilise the Open Source platform to help build their careers related in field of Linux systems Design and Development.
Q. What will be the outcome of this course?
A. The students upon completion will definitely have a SOLID understanding of Linux System Programming, For freshers this can be a good guide to crack interviews, for already working professionals they can start working as individual contributor in their projects, and definitely will be in par with the experienced colleagues.
Q. What are the contents of course?
In this course you will be learning the below Linux system programming. And more emphasis is given on the Programming part.
1. Introduction to Linux systems.
a. Linux architecture.
b. Writing 'Hello World' program, compiling using GCC and its execution.
2. What is system call and standard library function calls
3. Kernel and User mode in Linux
4. File operations
open(), close(), read(), write(), lseek()
Blocking and Non-Blocking calls.
Atomic operations, Race condition.
5. Memory Management and Virtual Memory
stack segment, code segment, heap segment, data segment,
Virtual memory management.
functions related to Memory allocation - Malloc(), calloc(), Realloc(), Auto variables, static variables.
6. Process Management
Process creation, Process termination, wait(), Process ID, fork() system call, Exec() family of system call, Parent-Child Process management,
Command line arguments of Process.
7. Signals
signal(), signal handlers, sending signals to process, ignoring and default signal actions.
8. Posix Threads
Thread creation, thread termination, thread ID, joinable and detachable threads.
9. Thread synchronisation
Mutex, Condition variables, Thread safe.
10. Posix - Inter Process communication.
Pipes, FIFO, Posix message Queue, Posix Semaphores, Posix Shared Memory.
NOTE - Ubuntu Distribution (Linux) is used for all Demo in this course.