CS311 Introduction to Operating Systems I - Summer 2009
Download
Report
Transcript CS311 Introduction to Operating Systems I - Summer 2009
CS311 – Lecture 24 Outline
• Final Exam Study Guide
Note: These lecture notes are not intended replace your notes. This is
what I expect your notes to already look like, but with more explanation as
needed.
Lecture 24
CS311 – Operating Systems 1
1
Shell Commands and Utilities
• shell commands
– know all the basic ones with common options.
ls, cd, chmod, mkdir, rm, rmdir, cat, echo, ps, sleep, sort,
wc, man, mv, cp, pwd, kill, chgrp, chown, newgrp, touch,
gcc
• input and output redirection (<, >, >>)
• command line pipes like ls | wc
• built in variables like $#, $1, $2, $USER, $PATH, …
Lecture 24
CS311 – Operating Systems 1
2
Shell Commands and Utilities
• background processes -- sort $file1 &
• variable substitution -- Example: echo "$x was
entered by the user"
• command substitution -- Example: listOFiles=`ls`
• wildcards -- Example: ls *.java
• What are the 3 steps the shell goes through to find
the command?
• Use of double quotes vs. single quotes vs. back ticks
Lecture 24
CS311 – Operating Systems 1
3
Bash Script
• Can you write a simple bash script on the exam?
– What is the proper shebang line if you want the bash shell
to interpret the script?
– Can you write an if statement correctly?
– Can you use the test command to see if 2 variables are
equal or if a file exists?
– Can you write a for loop correctly?
Lecture 24
CS311 – Operating Systems 1
4
Powerful Unix Utilities
• awk
– You might be asked to interpret a simple awk program.
– awk variables: NR, NF, $0, $1
• sed
– Can you use sed to delete certain lines?
– Can you use sed to substitute occurrences of a regular
expression with a string?
• grep - can you use grep to find a specific pattern
Lecture 24
CS311 – Operating Systems 1
5
Regular Expressions
• You should know the extended regular
expressions
– ., *, +, ?, ^, $, [...], [^...], \, ( )
– Can you say whether or not a line will match a
given regular expression?
– Can you say exactly what will match?
– Given a description of what to match, can you
write a regular expression that works
Lecture 24
CS311 – Operating Systems 1
6
Features of modern operating systems
• multiprogramming vs. time-sharing
• Explain why multiprogramming and timesharing are
important for modern operating systems.
• Reproduce the diagram of the organization of Unix.
• Describe the memory organization of a typical process in
a common operating system.
• What is a context switch?
– Ans: It is when a process is switched out of the microprocessor
and another is switched in. It is costly in terms of cycles because
so much information must be saved so that when the old
process is resumed, everything is as it was.
Lecture 24
CS311 – Operating Systems 1
7
Process Management
• What does a child process inherit from its parent?
– I'm looking for things such as: variables, open file
descriptors, signal handling.
• What is different between parent and child?
– They have different pid numbers, different parents,
different physical memory, different CPU usage statistics
• What is a zombie?
• What is an orphan?
Lecture 24
CS311 – Operating Systems 1
8
makefiles
• I could ask you to look at a makefile and
predict what will print to the screen after
certain commands from the command line.
• I could ask you to write a simple makefile.
Lecture 24
CS311 – Operating Systems 1
9
System Calls
• You will be reading / writing code with any of the following
system calls:
–
–
–
–
–
–
–
open
close
lseek
read
write
dup2
fork--know what fork returns to the parent and to the child (and what
if it fails)
– wait or waitpid (What do these functions return?)
– exec family of calls - know how to write execlp or execvp for the exam
– pipe
Lecture 24
CS311 – Operating Systems 1
10
File System
• If I give you a sequence of commands (fork, dup2,
open, close), can you draw the diagrams of the
processes' file descriptor tables, the system file table,
and the in-memory i-node table?
• What information is contained in an i-node? What is
NOT in an i-node?
• How are an i-node's direct, single indirect, double
indirect, and triple indirect pointers used to access a
file's data blocks?
• Name some types of files.
Lecture 24
CS311 – Operating Systems 1
11
File System - Hard links and Soft links
• What is the difference between hard links and soft
links?
• What happens if a user types (draw a picture of
directory, inodes, data blocks)
ln oldFile newFile
• What happens if a user types (draw a picture of
directory, inodes, data blocks)
ln -s oldFile newSoftLinkFile
Lecture 24
CS311 – Operating Systems 1
12
Signals
• Can you follow code that
– creates signal handlers with sigaction?
– sends signals with kill?
– contains fork()?
• You will be asked to predict the outcome of typing
Ctrl-C at specific times.
• What is the difference between ignoring a signal and
blocking a signal?
• Can you kill one of my processes? Can you kill one of
your own?
• What is the default action for SIGINT?
Lecture 24
CS311 – Operating Systems 1
13
Version Control
• Why use version control?
• Can you set up an SVN repository, check in a
file, and check it out for editing?
Lecture 24
CS311 – Operating Systems 1
14