Chabot College Fall 2002 Removed Fall 2006 Course Outline for Computer Science 18B LINUX SYSTEMS PROGRAMMING I Catalog Description: 18B - Linux Systems Programming I 2 units Introduction to the Linux operating system and its resources. Concepts of multi-tasking operating systems, system calls, process control. Basic Linux shells, file handling, inter-process communication, and resource sharing. Prerequisite: Computer Science 15 or Computer Science 18A and Computer Science 42 (all completed with a grade of C or higher). 1.5 hours lecture, 1.5 hours laboratory. Prerequisite Skills: Before entering the course the student should be able to: 1. explain the steps in the software engineering lifecycle; 2. use accepted design methods (structure charts, pseudocode, simple class diagrams) to develop and code several (six-ten) programs of intermediate difficulty and length in the C++ language, including programs broken into several files; 3. adhere to style and documentation standards in writing programs; 4. use system debuggers to step into and over code, set breakpoints and watch variables; 5. identify what makes a good test data suite and use it to thoroughly test a program under development; 6. write C++ overloaded functions, simple recursive functions, function templates; 7. define, initialize, dereference and manipulate pointers; 8. manipulate arrays using pointer notation; 9. define, design and use simple C++ classes, including at least one project that uses a class inheritance hierarchy; 10. manipulate both standard C-strings using the cstring library and string objects using the ANSI string library; 11. overload C++ operators both as member functions and friend functions; 12. define and use virtual member functions to implement polymorphic behavior; 13. identify bitwise, unary and binary scope resolution, and conditional operators; 14. use the new and delete operators to implement a singly linked list; 15. be proficient in using UNIX tools; 16. know about the Linux variant of UNIX; 17. have a working knowledge of enhanced UNIX shells; 18. be able to program and use shell scripts; 19. have a basic knowledge of awk; 20. be familiar with process control; 21. be familiar with security issues; 22. be familiar with basic system administration concepts and procedures. Expected Outcomes for Students: Upon completion of the course the student should be able to: 1. 2. 3. 4. 5. identify the differences between the C standard libraries and Linux libraries; design, write, debug and document well-structured programs of small- to medium- length in the C language, using Linux system resources and the Linux libraries; demonstrate familiarity with processes under Linux and create, signal, and kill processes; demonstrate familiarity with Linux multitasking and describe, at a high level, how multitasking is done in Linux; demonstrate familiarity with semaphores in Linux and write C programs that correctly use semaphores; Chabot College Course Outline for Computer Science 18B Fall Semester 2002 Page 2 Expected Outcomes for Students: continued 6. 7. 8. 9. 10. 11. 12. 13. demonstrate familiarity with interprocess communication (IPC) signals in Linux and write C programs that correctly send and handle signals; demonstrate familiarity with shared resources (such as shared memory) in Linux and write C programs that correctly use shared resources; demonstrate familiarity with other Linux IPC tools, such as pipes and message queues, and write C programs that use these tools; identify parent and child processes, and user and group ids of processes; demonstrate familiarity with the internal workings of a simple shell, and write a simple shell; demonstrate familiarity with daemons and write a simple daemon; handle runtime errors from within C programs; demonstrate familiarity with networks as a user. Course Content: 1. 2. 3. 4. 5. 6. 7. The Linux operating system overview a. Differences between Linux and other UNIX variations, the GNU software license b. Multi-tasking and multi-user operating systems, the kernel, shells and processes c. Linux system calls vs. C library calls, user mode vs. kernel mode Review development tools a. gcc and make Linux O/S services a. The unistd library and system services b. Manipulating processes, environment variables, setuid and setgid programs b. Getting user and process information, process and parent ID's c. Managing processes: system(), fork() and the exec() family of system calls, wait() d. Killing processes, exit(), abort() and kill() Signals a. More about kill(), the kill command and the kill() function b. Waiting for events, alarm(), pause(), general signal handling with the signal library c. Using a signal handler System calls a. The difference between C library and system calls, why do you need system calls? b. Classes of system calls: process management, file I/O, memory management, and signal handling and IPC c. Error codes from system calls and how to handle errors Basic Linux file handling a. The difference between C-library file handling and Linux kernel file handling b. File permissions and types, introduction to special files and devices (FIFO, device, symbolic link, regular file, socket, directory, block device) c. The file mode bits: type, access and modifier; the umask d. The file handling interface: stat(), open(), creat(), close(), read(), write(), lseek(), etc. e. Stream and random access files The GNU debugger (Optional) a. Using gdb for logic and memory errors b. Types of memory bugs (leaks, corruption and illegal access). c. Other debugging tools (for example, Electric Fence, mpr, mcheck) Chabot College Course Outline for Computer Science 18B Fall Semester 2002 Page 3 Methods of Presentation: 1. 2. Lecture In-class example programs with explanations and demonstrations Assignments and Methods of Evaluating Student Progress: 1. 2. Typical Assignments a. Small programming assignments illustrating main points from lecture 1) Create a program that uses fork() and exec() to create a child process, and then waits for the child to exit inside the parent process. 2) Create a program that prints its own ID and group ID and its parents ID and group ID. b. Non-programming homework to reinforce concepts from lectures and reading 1) At the command line, create and suspend several processes from several different shells, then run ps. Use the output from ps to write a genealogy of the processes. 2) Use gdb to trace execution of a program and report statistics on the systems calls. Methods of Evaluating Student Progress a. Midterm exam(s) b. Optional short quizzes c. Final Exam Textbook(s) (Typical): Linux Programming by Example, Kurt Wall, Que Corporation, 2000 Special Student Materials: Computer lab fee Diskettes Optional zip disk July 2001 Keith Mehl Hps CS 18B Outline Fall 2002