Professional Documents
Culture Documents
Lecture 1 Slides
Lecture 1 Slides
Course Overview
C++, Unix, Compiling, g++, …
Instructor
Thomas Reichherzer
treichherzer@uwf.edu
• A software program
• mediates between hardware resources and user
• Linux/UNIX Kernel
• A resource allocator.
• A control program.
• Examples: Windows Family, Linux Family, UNIX
(Berkeley, ATT Bell Labs)
(On UNIX see
http://www.unix.org/what_is_unix/history_timeline.html)
System Commands
OS
System Calls
Kernel
Hardware
user
user
system calls
users system
kernel functions
hardware
application system
programs programs
COP4634 9
L01 Overview
Computer System Components
• Hardware:
• CPU, Memory
• Operating system:
• device driver
• interrupt handler
• scheduler
• …
• Application programs:
• use system resources (e.g. libraries)
• provide interfaces to access system resources
disk
CPU disk
controller
graphics
memory USB
adapter
controller
(http://techwiseuk.com/wp-content/uploads/2012/09/CPU.jpg) www.uptechnologysolutions.com
memory
A registers A registers
C C
L L
U U
U L1 cache U L1 cache
L2 cache L2 cache
L3 cache
memory
Program Program
Monitor Monitor Monitor …
A B
User Program
• CPU scheduling
(discussed in details later)
many terminals
one mainframe
http://www.youtube.com/watch?v=Anxxe8SdX78
handler routine 1
Hardware
….
interrupts
….
Exceptions handler routine 65
Software
interrupts
(trap)
• IO device such as
• keyboard
• mouse
• network card
• …
• Timer when the time slice has expired to return
control back to the OS.
• Programs when
• a system call is executed
• a run-time error occurs
cache
threads of executions
CPU
IO Devices
COP4634 31
L01 Overview
Dual-Mode Protection
user mode
make return from process executing
process executing
system call system call
User Mode
BASE LIMIT
1280 4096
Types of System
Call
user application
• process control
• file operations
open() • device operations
• communication
• …
system call interface
System Call Examples
exit()
open(): fork()
implementation of allocate() / free()
system call
open() / close() /
return write() / read()
L01 Overview COP4634 40
Metric System (Powers of 10)
• Internet Forums
StackOverlow
man
man –k search-word
man –s section specific-name
Sections
1 User commands 7 Devices
2 System calls 8 Maintenance
3 Standard library commands and file
functions formats
4 Interface libraries 9 Kernel functions for
drivers
5 Headers
n Miscellaneous libraries
6 Games and demos
COP4634 48
L01 Overview
Compilation (simplified)
pre-
compiler linker executable
processor
inter-
mediate object
code code
#include directives
#define directives
Namespace directives
Class definitions
main() definition
clean :
rm test test.o sort.o
COP4634 56
L01 Overview
Makefiles Examples (cont.)
test : $(objects)
g++ –o test $(objects)
clean :
rm test $(objects)
COP4634 57
L01 Overview
Makefiles Examples (cont.)
3. Letting make deduce the commands using an implicit rule for updating .o
files.
objects = test.o sort.o
test : $(objects)
g++ –o test $(objects)
.PHONY : clean
clean :
rm test $(objects)
COP4634 58
L01 Overview
Key take-away