UNIX/Linux & C Programming:
Chapter 1: Introduction to UNIX/Linux & C Programming

This is a book on UNIX/Linux and C.

What is systems programming?

  • generally, developing programs that support the development of other programs
  • the process of developing systems software

What is systems software?

  • software that supports software development, or a computer system in general
  • software that allocates and manages computer resources (e.g., CPU, memory, devices)

Examples of systems software

  • assemblers
  • compilers (e.g., gcc)
  • linkers
  • loaders
  • command interpreters (i.e., shells, e.g., bash)
  • system libraries (e.g., libc)
  • device drivers
  • debuggers (e.g., gdb)
  • system utilities (e.g., env)
  • configuration managers (e.g., git)
  • compilation managers (e.g., make)

One dichotomy of programming

  • application programming: targeted toward developing systems to support the end-user
  • systems programming: targeted toward developing systems to support the programmer
  • Recently, this boundary has become fuzzy. Building a web browser, such as Google Chrome might once have been considered application programming. However, nowadays developing such applications requires attention to system details such as resources and efficiency (e.g., Google Chrome is multi-processed).

    Historically, systems programming meant programming the system (i.e., building compilers, shells, loaders, and so on). However, nowadays, systems programming has come to mean programming with the system (i.e., making system calls, managing threads, and so on).

    We could also say that computer science students study programming software while computer engineering students study programming the interface between hardware and software (historically, they studied programming hardware).

Another viewpoint (course themes)

  • systems programming requires a greater awareness of issues of hardware and efficiency than application programming;
    what does the following C code do? while (*p++ = *q++);
  • since systems programs typically run for a long time and, therefore, must be robust and fault tolerant, systems programmers must be diligent to release resources and check for errors (e.g., a NULL pointer as a return value) in more than just the typical places in a program; why is the following code unportable or unsafe?
    char c;
    while ((c = getchar()) != EOF)
  • systems programming is characterized by the use of languages at a lower level than those used in application programming; one that provides the programmer direct access to and control of system resources; leads us to UNIX and C

Review of operating system nomenclature

  • program vs. (heavyweight) process

  • thread (lightweight process):
    • an ADT within a process
    • has its own stack, program counter value, register set, and state
    • share process resources (e.g., open files)

  • (heavyweight) process vs. (lightweight) thread

  • process control block
  • bootstrapping
  • batch process
  • resident monitor
  • multiprogramming
  • time sharing (sometimes called multitasking)
  • multiprogramming is sometimes referred to as non-preemptive or cooperative multitasking
  • time sharing is sometimes referred to as preemptive multitasking
  • job scheduling
  • ready queue
  • process scheduling
  • process scheduling (or CPU scheduling)
  • context switch
  • context switch time
  • quantum (or time slice)
  • system call
  • interrupt (hardware)
  • interrupt service routine
  • (asynchronous or synchronous) signal (software)
  • asynchronous event
  • synchronous event
  • device driver
  • paging
  • segmentation
  • paged segmentation
  • UNIX is a multiprogramming, timeshared OS.

Why study this stuff anyway?

  • an improved understanding/appreciation of the internals of your system and systems software will make you a better application programmer
  • UNIX and C are an enabling environment/language for wide variety of science and engineering disciplines (e.g., bioinformatics)
  • since UNIX and C are ubiquitous in our field, in general, to be a well-rounded computer scientist
  • communication and concurrency are everything in today's software
  • ability to write reliable and secure code is indispensable (cybersecurity, counter-terrorism)
  • gateway to studies in distributed computing and networking

Course objectives

  • Develop a proficiency in UNIX/Linux and C.
  • Establish an understanding of the Linux style of programming and problem solving.
  • Survey various system-oriented software tools, including debuggers, and compilation and configuration managers.
  • Establish an understanding of the design and development of systems software, such as command shells and parsers, through the study of pattern matching and filters, interprocess communication, system libraries, signals, and automatic program generation.
  • Explore UNIX internals and establish an understanding of UNIX system calls.
  • Introduce the client/server model.

OOP vs. Linux model of programming/problem solving

Key: ◯ = object, ▢ = process, → = message or data, { or } = thread, and ~ = pipe.

Object-oriented model of programming/problem solving           UNIX model of programming/problem solving
sequential           parallel
re-compile           re-configure

Overview of book outline

We aim for breadth rather than depth here.
Return Home