
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.
Explore how Linux uses user mode and kernel mode to protect hardware resources, with system calls and library calls enabling transitions from user space to kernel space.
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
Explore Linux file concepts, including ownership, permission bits (read, write, execute), and file types from files to links, and learn to view and change permissions with ls -l and chmod.
Open system call returns a file descriptor and uses default descriptors for standard input, output, and error. Use O_RDONLY, O_WRONLY, O_RDWR, and O_CREAT with mode.
Discover how the read() system call reads bytes into a user-space buffer from a file descriptor obtained via open(), including end-of-file and error handling, with examples.
Explain how the write() system call writes data from a user-space buffer to a file, using a file descriptor obtained from open(), a buffer pointer, and a count.
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 the program versus process concept, examine process memory layout and sections, and learn process id, parent process id, and how preprocessing, compiling, assembling, linking, and loading form an executable.
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.
Examine the basic process memory layout, including the text segment with program code, data (initialized and BSS), stack, and heap, and how stack frames store locals for dynamic allocation.
Explore how a C program's memory partitions into text segment, initialized data segment, uninitialized data segment, stack, and heap, with static variables and malloc illustrating each segment.
Summary related to Process
Understand virtual memory, how Linux multiprocess systems provide each process with more addressing space than physical RAM, and how private memory protects data across processes.
Explore how virtual memory manages process memory, page frames, page tables, and swap between RAM and disk, and illustrate page faults in Linux.
Learn how command line arguments work in a process with argc and argv, print strings, and convert ASCII inputs to integers for add or subtract operations.
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.
Explore memory allocations in Linux system programming, including malloc, calloc, realloc, and the break and s break system calls. See how the heap grows with dynamic memory.
Understand memory in Linux with malloc, calloc, realloc, and free; free returns blocks to free list without lowering program break, while alloc A allocates on stack and risks overflow.
Explain how the fork system call creates a child process, duplicating the parent’s memory and creating separate virtual memory for text, data, and stack via copy-on-write.
Explore how orphan and zombie processes form during forking, and how a sleeping child affects scheduling. Learn how reparenting to init and wait calls remove zombies from the process table.
Learn how the exec system call replaces a running program by loading a new program into memory, discarding the old one, and starting execution from main using argv and envp.
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.