In-class notes for 08/28/2020
CS 273 (OS), Fall 2020
Upcoming homework assignment HW2, due Monday "midnight"
For full credit, submit at least part on time, then complete the rest within a week.
Environment variables - access using third argument of
main()
First project will be due on September 21 (see below)
Submitted questions on assignments and technology
Use this form to submit questions for a future class meeting
Programming with system calls (mopen)
Selected Linux system calls
Selected Linux system calls
More file-related system calls
dup()
,pipe()
, etc.Each process has a kernel file descriptor array, with file descriptor as index and pointer to open-file data structures as values.
System calls for file systems, i.e., OS components that contain files and directories
mount()
,umount()
, etc.
Other components of an OS besides file system
Devices
ioctl()
, for setting parameters for an I/O (input-output) device (will return for code illustration)Berkeley socket calls, for network I/O (will return later)
Specialized device calls, e.g., time-related calls for interacting with clock device (will return)
Memory management
brk()
,sbrk()
, for adjusting how much main memory is allocated to a process.
Process management system calls
fork(), execve(), exit(), wait(), waitpid()
Example code: ~rab/os/egs/forkeg.c
(
fork()
,execve()
, andwait()
implement the key ideas in the Linux strategy for starting new programs.)zombie process -- process called
exit()
, but its parent hasn't calledwait()
for it to collect its exit status, so that exited process continues to take up OS resources.
Process diagrams for describing system calls
Inclass examples:
uniq file.out > myfile2
uniq < file.out > myfile2
sort myfile | uniq > myfile2
sort < myfile | uniq >> myfile2
Shell project assignment
Basic idea
-
Report (overview, system calls, known bugs, 1-2 pg experiences)
Extra features that use system calls. E.g., redirect output, pipe,
cd
; path search counts (useexecve()
system call)
Strategy for developing a shell
Lab2 on parsing -- step 1 in strategy
We now know enough to announce the first project -- to write a Linux shell using system calls. Project assignment page
Will discuss this project later, but you can start now if you want. Be sure to see the strategy recommendations for incrementally developing your shell.
Reading questions
< >