Title: Introduction to Computer Engineering
1Introduction to Computer Engineering
- Stamatis Vassiliadis / Georgi N. Gaydadjiev
- Computer Engineering Laboratory
- EEMCS
- Delft University of Technology
2Software
- COMPUTER
- Without any Software
- Made of iron noisy box
- To fill empty places
- With Software
- Process / store data
- Play songs and media clips
- Recognize your voice commands
- Calculate complex mathematics equations
- SOFTWARE IS DIVIDED IN
- Application Software
- System Software
3Software Transformations
- People speak English, Chinese, Dutch, etc
- Computers understand only binary tokens
- Complex transformations are needed to maintain
man-machine communication (HLL-Low Level-Bin)
ori 1, 0, 15 addiu 1, 1,
7 (MIPS-assembly)
int i i 15 i i 7 (C-code)
001101 00000 00001 0000000000001111 001001 00001
00001 0000000000000111 (MIPS-machine
instructions)
4Data representation in computers
- Humans Use numbers like 22, 7, 253 etc. (base 10
system) - Computers Recognize only two (electrical) values
(TRUE and FALSE) (1 / 0) Understand numbers
like 10110, 111, 11111101 etc. (base 2)
- LSB first / MSB first
- Big Endian / Little Endian
5Representing Real Numbers
- How to represent negative numbers
- How to represent huge numbers
1 10000001 10100000000000000000000 -1 x 1.1012
x 2(129-127) -1 x 1.5 x 4 -6.5
More representing text (ASCII, EDBC), Boolean
variables, Data structures
6Compilers
compiler
source program
target program
error messages
Used to be considered as the most complex
programming projects on the past.
With modern techniques even short student
projects became possible.
7Formal Languages (N. Chomsky 1950s)
(defining languages and their grammar with
mathematical precision)
- Terminal symbols
- Nonterminal symbols
- Set of syntactic equations
- Start symbol
S A A a A ?.
L ?, a, aa, aaa, aaaa, ...
S A A a A c b.
L b, abc, aabcc, aaabccc, ...
BNF and EBNF notations are good examples
8Compilation Process
velocity initial_velocity
acceleration time
9Additional Compiler Components
symbol-table manager
Code optimizer
lexical analyser
code generator
syntax analyser
semantic analyser
source program
object program
error handler
10Statement Translation (all steps together)
velocity initial_velocity 100 time
lexical analyzer
id1 id2 100 id3
syntax analyzer
semantic analyzer
intermediate code generator
temp1 inttoreal(100) temp2 id3
temp1 temp3 id2 temp2 id1 temp3
11Statement Translation II
temp1 inttoreal(100) temp2 id3
temp1 temp3 id2 temp2 id1 temp3
code optimizer
temp1 id3 100.0 id1 id2 temp1
code generator
MOVF id3, R2 MULF 100.0, R2 MOVF
id2, R1 ADDF R2, R1 MOVF R1, id1
12Compiler related tools
- Preprocessors
- Macro processing
- File Inclusion
- Language augmentation
- Language extension
- Assemblers
- Compiler construction tools
- Parser generators
- Scanner Generators
- Automatic code generators
define SETBIT(byte,bit_nr) (byte (1ltlt(bit_nr
mod 8))) define DTR 5
SETBIT( uart_register, DTR ) Instead
of uart_register 1 ltlt 5
include ltstdio.hgt include main.h
13Interpreters
- Direct code execution (instead of translation)
error generation debugging are harder
14Operating System (OS)
- SOFTWARE LAYER
- That hides the system complexity and presents
simpler view - (User / top-down view)
- Convenient interface
- Easy programming of interrupts, timers, memory,
communication devices, etc. -
- That manages the available resources
- (System / bottom-up view)
- Controls resource allocation among many
applications memory, CPU, disk access, etc. - Deals with multiple users environment
Both views are somehow contradicting, but are
equally important!
15OS Main Issues
- Programming API how should the application
interface look like? - Resource management how should the hardware
resources be multiplexed among multiple users /
programs? - Sharing how should resources be shared among
multiple users? - Security how to protect users / programs from
each other? How to project the OS from
applications and users? - Communication how can applications exchange
information? - Structure how to organize the OS?
- Concurrency how to deal with simultaneous
requests? - Performance how to make OS run as fast as
possible? - Reliability how to keep the OS always running?
- Accounting how to keep track of resource usage?
- Distribution how to use multiple computers in
conjunction? - Scaling how to keep the OS efficient and
reliable as the imposed load grows?
16OS position in computing device and some examples
- MS Windows
- Win 9x
- Win NT
- Win 2k
- Win XP
- UNIX
- SUN
- HP
- Irix
- BSD
- MAC OS X
- Linux
- VxWorks (Wind River)
- DOS
17Processes in OS
- Process - a program in execution
- Consisting of
- CORE IMAGE executable program, data and stack
- OS ADMINISTRATION process ID and state,
registers status, stack pointer, program counter,
I/O status (e.g. files and comm. endpoints) etc.
A running
A suspended
B running
B suspended
OS Adm.
OS Adm.
OS Adm.
machine
machine
2
1
18Processes creation and hierarchy
- How to create a process? System call.
- A single program can be used to initiate several
processes (it is not 1-1 relation) - Processes can give birth to other processes (of
the same or different program) - fork() exec()
19Process Scheduling
- First-Come-First-Serve (FCFS)
- Shortest-Job-First (SJF) non preemptive,
preemptive - Priority Scheduling non preemptive, preemptive
- Round Robin
A
B
C
D
RR disadvantage too small quantum can decrease
system throughput!
20Inter process Messaging Signals and Pipes
- Signals short asynchronous event notifications
- Predefined events segment violation, message
arrival, kill, etc. - Pipes used to send arbitrary amounts of data
int fd2 if (pipe(fd) lt 0) / got an error,
check errno /
21Process Dependencies
Producer-consumer relationship
22Process semaphores
Global variable s Semaphore 1 / initial
value is 1 /
Process 1 . . . begin P(s) end / begin
exclusion / . . . critical section . .
. begin V(s) end / end exclusion / . . .
Process 2 . . . begin P(s) end / begin
exclusion / . . . critical section . .
. begin V(s) end / end exclusion / . . .
23File System
A file system is a storage abstraction illusion
of structured storage space
- File creation, deletion
- File reading, writing
- File open, close
Similar organization as processes but also
quite different
24System calls
- A System Call is the main way for user program to
interact with the Operating System.
25Memory Management
Size
Speed
81 GB/s Pentium 4 2.53 GHz
160GB single disk
1GB single module
8,2 GB/s RDRAM Dual 600 MHz
1MB Reg., L1, L2
80 MB/s Ultra-2 SCSI
Mass Storage
Main Memory
On Chip Memory
26Memory Management, continued
- When programs become too big to fit in the memory
at once - Slice in pieces and keep them on the disk
Physical address space
Virtual address space
2
0-4K 4K-8K 8K-12K 12K-16K
0-4K 4K-8K 8K-12K 12K-16K 16K-20K 20K-24K 24
K-28K 28K-32K
1
X
X
0
page frame
X
3
Hardware MMU
X
27Operating System Structure Monolithic Systems
- Collection of procedures
- Each one with well defined interface
- But no restriction on internal calls exists
- Object program is a linked image of all proc.
Can this be fixed ?
This organization suggests a basic structure for
the OS Main program that invokes the
requested service procedure A set of
service procedures to carry out the system
calls A set of utility procedures that
help the service procedures
Note how all layers have direct hardware access!
28Operating System Structure Layered Systems
- Organize OS as a hierarchy of layers each one
constructed upon the one below it - Clear interface and layer functionality
- Manageable OS development
- Easier maintenance and security
29Operating System Structure Virtual Machines
- Virtual Monitor runs on the bare hardware and
provides several virtual machines to the next
layer - Virtual Machines are not extended machines (with
file system, etc.) but present exact copy of the
hardware, including memory, I/O, interrupts, etc. - Each VM can run any OS
30Operating System Structure Client-Server Systems
- Modern trend is to simplify the kernel
- Process, file, memory management are moved to
higher layers (in user mode) - Client process sends a request to a server
process to request a service (e.g. reading a file)
31Real Time OS
- Running applications have time deadlines by when
they have to complete certain tasks - Hard real-time system
- Medical imaging systems, industrial control
systems, etc. - Catastrophic failure if miss a deadline
- What happens if collision avoidance software on
an airplane does not detect another plane before
the turning or breaking distance? - Challenge lies in how to meet all deadlines with
minimal resource waste - Soft real-time system
- Multimedia applications
- May be annoying but is not catastrophic if a few
deadlines are missed - Challenge lies in how to meet most deadlines with
minimal resource waste
32Embedded OS
- Pervasive computing
- Right now, cell phones and PDAs
- Future, computational devices everywhere
- Characteristics
- Constrained resources slow CPU, small memories,
no disk, etc. - Whats new about this? Isnt this just like the
old computers? - no, because we want to execute programs more
efficiently - usually the user interface is different
- the system runs continuously (if not forever)
- OS support for power management, mobility,
resource discovery, etc.
33Final Notes
- Next week the hardware discussion will be
started