Embedded Linux Systems / User Space Programming

מק"ט: #5911 | משך קורס: 40 שעות אק'

This course is about user space programming in Linux in C.
It covers all major areas of programming (processes, threads, IO, networking, synchronization and more).
It includes exercises (usually one exercise for every major chapter).

C++ is not covered as it is yet another thin layer on top of C and does not change the system API in any way nor change any of the best practices learned

לפרטים נוספים, מלא את פרטיך או התקשר 03-7100673
*שדות חובה


  • Understand the Linux userspace API
  • Use that API to build efficient Linux programs

קהל יעד

  • C programmers who are not familiar with the Linux API
  • C programmers who are familiar with UNIX API and would like to understand the Linux extensions of that API
  • C programmers who want to build efficient programs on the Linux operating system
  • Embedded Developers

תנאי קדם

  • Experience in C programming is a must


Protected operating system theory

  • Protectd OS definition.
  • Why is the definition important?
  • How does privelege work?
  • How does memory protection work?
  • How do system calls work?


Tools (this chapter is needed for the following exercises)

  • The gcc compiler.
  • Some make syntax.
  • Compiling apps.
  • Compiling libraries.
  • Making the apps find the libraries.
  • Best practices.



  • The process tree.
  • /sbin/init and startup/shutdown.
  • Creating processes.
  • Waiting for processes to change state/die.
    • With signals handling.
    • With the wait*(2) famility of functions.
    • Using a signalfd(2) and multiplexing.
  • Analyzing the processes return value.
  • Process state transition.
  • Adoption.
  • Zombies and solutions.
  • Fork performance and vfork.
  • fork(2)/exec*(2) way of doing things.
  • system(3),popen(3).
  • shells and how are they implemented.
  • If fork(2) a good API? (compared to other operating systems).
  • There are no threads in Linux (clone(2)).
  • Advanced material:
    • Process groups.
    • Sessions.
    • Controlling terminals.
    • Writing your own process reapers.
    • Children getting signals about their parents dying.



  • What is a pipe / fifo.
  • The pipe() system call.
  • EOF condition.
  • File descriptor table after fork.
  • File descriptor table after exec.
  • Using dup().
  • popen().
  • inetd example – Sockets instead of pipes but still the same.
  • Limitations of pipe().
  • Named pipes.


Signal Handling

  • Why signals?
  • The problems created by asynchronous delivery.
  • Overcoming the async problem of signals.
    • routing back to main context.
    • sigprocmask
    • signal safe functions
  • How are signals implemented?
    • When a process is in user space.
    • When a process is in kernel space.
    • In real time linux.
  • Receiving signals synchronously.
  • The problem of single delivery.
  • Jumping out of signal context to regular context.
  • Signal interruption.
  • The various signals and their semantics and usage.



  • The pthread library.
  • Creating threads.
  • Waiting for threads to die.
  • Detached threads.
  • Thread mutexes and their kinds.
  • How are futexes implemented?
    • Using futexes for process synchronization.
  • Barriers
  • Conditions
  • Readers/Writer locks.
  • Spin locks.
  • pthreads and signals
  • cleanup facilities
  • cancellation facilities
  • thread affinities.
  • threads are not file descriptors and what can you do about it.


File API

  • The per process file descriptor table.
  • open/read/write/close
  • Explanation of the semantics of read/write.
  • Overcoming the read/write issues
    • mmap(2)
    • ioctl(2)
    • FILE* APIs.
    • C++ streaming APIs.
  • Manipulating files.
  • No locking in UNIX.
  • Directories.
  • Symbolic links.
  • Other file types.
  • Advanced: passing file desctiptors amongst unrelated processes.


The IO subsystem

  • How does it work?
  • The kernel page and buffer caches.
  • The performance of the io subsystem
  • ionice(2) and it's uses to control IO priority.
  • Overcoming the copy problem with O_DIRECT and it's problems.
  • Overcoming the copy problem with mmap.



  • Semaphores
  • Shared Memory
  • Message queues.
  • Performance compared to SYS V equivalents.



  • Writing SOCK_STREAM (TCP) servers and clients.
  • Writing SOCK_DGRAM (UDP) apps.
  • The various domains
    • AF_UNIX vs AF_INET
  • Using raw sockets.
  • Debugging tools for networking apps.


Multiplexing IO

  • What is the problem to solve?
  • What are the two possible solutions (multiplexing and ioports) and why is multiplexing better.
  • The various APIs for multiplexing in Linux (select, poll, epoll).
  • How to do multiplexing correctly?
  • Design patterns on top of multiplexing (Reactor/Proactor).