Uploaded by Tells

1computerarchso intro1

advertisement
SOME USEFUL INSTRUCTIONS BEFORE WE START
COMPUTER ARCHITECTURE &
OPERATING SYSTEMS
https://commons.wikimedia.org/wiki/File:Other-linux-logo.svg
https://commons.wikimedia.org/wiki/File:Windows_logo_%E2%80%93_2012_(dark_blue).svg
https://commons.wikimedia.org/wiki/File:Apple_logo_black.svg
1
“
Rule number 1.
YOU HAVE TO PASS!!
— ME
”
2
ABOUT THIS COURSE…
WHERE TO FIND WHAT AND WHAT TO DO.
•
•
Examination
•
1 written (multiple choice) exam
•
1 assignment (we will exercise in class for the assignment at home)
Study material
•
Slides
•
Material given
•
Reference book→“Modern operating system” 4thed. Tanenbaum, Bos.
NOTE: ALL THE MATERIAL IS REFERENCED IN THE SLIDES ACCORDING TO THE SOURCE
POLICY, IN EACH SLIDE ALL THE SOURCES,
MOST OF THE CONCEPTUAL CONTENT IS REFERRED FROM THE BOOK
3
THE ASSIGNMENT
SOMETHING TO KEEP IN MIND
•
The assignment is a script/program
•
Can be done in group of 2 (MAX)
•
More detailed information will be discussed in class.
•
•
It must respect all the rules in the description.
•
It must be original (NO COPY).
•
There is always the possibility of an ORAL CHECK on the content of
the assignment.
For any extra info about the course check the course manual in Teams
and Osiris
4
2 KIND OF CLASSES
HOW WE S TRUCTURED THE COURSE
•
Each week there will be 2 lessons:
1. One will be about how things work
2. One will be about experimenting with those things yourself
3. Or a mix of both
•
At any time:
•
FEEL FREE TO INTERRUPT TO ASK QUESTIONS FOR FURTHER
EXPLANATIONS!
•
But (at least try to) study (a bit ;) )
5
N.B.
SOME MORE GENERIC INFO
•
We will introduce notions of many concepts (in Operating systems
and Computer Architecture), some will be more in depth than others.
•
This course represents the entry to a world of information,
some of which will be explored in a future course
(both in DEV and ANL year 2).
•
Ex.:
•
Concurrency (ANL)
•
Networking (ANL)
•
Algorithm and Data structures (DEV)
6
SYMBOLS
LET’S SPEAK THE SAME L ANGUAGE
•
Talk with me, questions-answer,
discovery for each student
•
Talk with your colleagues
•
Take note
•
Exercise or question time
•
Check the video :)
THESE ARE THE GENERIC SYMBOLS I USE IN THE SLIDES, SOMETIMES THEY ARE IN COMBINATION BUT THEY ARE
JUST REMINDER THAT MAKES LEVERAGE OVER THE IMAGE TO SET THE PARTICIPATION MODALITY IN A VISUAL
WAY.
7
GENERAL GUIDE…
LET’S BE ON THE SAME PAGE!
•
Did you find a mistake?
•
Did you find something that is unclear?
•
Do you know a better example that is more clear?
•
HELP US TO MAKE IT BETTER! :)
•
Let your teacher/responsible of the course know about it so we
can improve it!
8
… WHAT IS A COMPUTER AND
HOW IT WORKS OR …
COMPUTER ARCHITECTURE
&
OPERATING SYSTEMS
9
SUMMARY
COMPUTER ARC HITECTURE
A definition
•
A brief intro to the history of a “computer”
PA
•
RT
O
F
TH
IS
IS
A
RE
VI
•
Example from far past
•
Example from …, well… you understand.
M
Example from far far past
O
•
FR
Example from far far far away past
EW
•
O
P1
!
•
Some more about OS and intro to the next lesson.
10
WHAT IS A COMPUTER?
PA
RT
O
F
TH
IS
IS
A
RE
VI
EW
FR
O
M
O
P1
!
11
WHAT WAS A COMPUTER?
PA
RT
O
F
TH
IS
IS
A
RE
VI
EW
FR
O
M
O
P1
!
•
Take note of the fundamental characteristics of what you will see
in the video (you will find it IN ADVANCE on the team files, watch
all of them before class ;) )
•
We will discuss the question together!
12
HERE A NEW VIDEO FROM NOT TOO LONG AGO…
YOUTUBE… NOT SPONSORED ;)
•
https://www.youtube.com/watch?v=IgF3OX8nT0w
13
DEFINITION1
computer |kəmˈpjuːtə|
noun
An electronic device which is capable of receiving
information (data) in a particular form and of performing a
sequence of operations in accordance with a predetermined
but variable set of procedural instructions (program) to
produce a result in the form of information or signals.
a person who makes calculations, especially with a
calculating machine.
Oxford Dictionary of English
Copyright © 2010, 2017 by Oxford University Press. All rights reserved.
14
DEFINITION2
[to] compute |kəmˈpjuːt|
verb [with object]
reckon or calculate (a figure or amount): the hire charge is
computed on a daily basis.
[no object, with negative] informal seem reasonable; make sense:
the idea of a woman alone in a pub did not compute.
[from the phrase does not compute, once used as an error
message in computing.]
ORIGIN
early 17th century:
from French computer or Latin computare,
from com- ‘together’ + putare ‘to settle (an account)’.
Oxford Dictionary of English
Copyright © 2010, 2017 by Oxford University Press. All rights reserved.
15
A
RE
VI
EW
FR
O
ANCIENT HISTORY
M
O
P1
!
•
The First!
•
Abacus
since
~2400 BC
https://en.wikipedia.org/wiki/File:Salaminische_Tafel_Salamis_Tablet_nach_Wilhelm_Kubitschek_Numismatische_Zeitschrift_Bd_31_Wien_1899_p._394_ff.jpg
Math existed LONG before we
had a real computer.
16
https://en.wikipedia.org/wiki/File:Abacus_6.png
A
RE
VI
EW
FR
O
ANCIENT HISTORY
M
O
P1
The about first!
•
Antichytera
Mechanism
https://en.wikipedia.org/wiki/Antikythera_mechanism
!
•
~205 BC60 BC
Orrery used to
predict astronomical positions
and eclipses for calendar and a
strological purposes. It could
also track the four-year cycle
of athletic games which was
similar (though not identical) to
an Olympiad, the cycle of
the ancient Olympic Games.
17
A
RE
EW
FR
O
M
O
Extra: https://arstechnica.com/science/2019/12/this-essential-piece-of-computing-history-just-sold-for-43750/
VI
HISTORY
P1
!
•
Jacquard loom
Joseph Marie Jacquard 1804
programmable textile machine
•
(Punched cards: value=yes/no)
https://commons.wikimedia.org/wiki/File:Morris_Dove_and_Rose_textile_1879.jpg
18
https://en.wikipedia.org/wiki/File:Hand-driven-jacquard-loom.jpg
A
RE
VI
EW
FR
O
MORE HISTORY
M
O
P1
!
•
Augusta Ada Byron (1815–1852)
Countess of Lovelace
•
First programmer ever
(she was a mathematician )
•
Created the first algorithm for
the analytical engine.
https://en.wikipedia.org/wiki/Ada_Lovelace
19
https://en.wikipedia.org/wiki/File:Ada_Lovelace_portrait.jpg
A
RE
VI
EW
FR
O
EVEN MORE…
M
O
P1
!
•
C. Babbage difference engine
between 1847 and 1849
•
First mechanical computer
•
Contained Arithmetic Logic
Unit (ALU), basic flow
control, punch cards (inspired
by the Jacquard Loom)
•
He refined after the analytical
engine.
20
(ONE OF) THE FIRST CALLED COMPUTER.
•
Example of the “computer” (1953)
youtube.com/watch?v=s1i-dnAH9Y4
A computer is a mechanical device until the ENIAC
21
A
RE
VI
EW
FR
O
FINALLY… SOME ELECTRONICS
M
O
P1
!
•
ENIAC:
Electronic Numerical Integrator
and Computer
•
February 15, 1946
•
Burning an average of 1 valve
every 2 days (after the initial
period where for each start or
stop cycle something was
burning).
•
Maximum period of time of
active computing, 116 hours—
close to five days with no breaks.
https://en.wikipedia.org/wiki/ENIAC
https://en.wikipedia.org/wiki/File:Eniac.jpg
22
A MOMENT IN TIME FOR HOLES…
WHIC H L AS TED ABOUT A CENTURY…
•
Punch(ed) cards:
•
Work independently from the processing
•
Representation of code
•
•
•
Encoded holes represented encoded values for each instruction
Representation of values
•
Numbers were encoded in columns not in binary
•
ex.: first column 0-9 printed values —> punched 3—> value 3
second column 0-9 printed values —> punched 4—>value 40
etc…
Extra: https://www.youtube.com/watch?v=YXE6HjN8heg
http://homepage.divms.uiowa.edu/~jones/cards/
23
https://en.wikipedia.org/wiki/Punched_card
A MOMENT IN TIME FOR HOLES…
WHIC H L AS TED ABOUT A CENTURY…
Source and rights to the: https://en.wikipedia.org/wiki/Punched_card
24
A
RE
VI
EW
FR
O
YES, HISTORY NEVER ENDS…
M
O
P1
!
•
Desktop Computers
(first 1964, programma 101, Olivetti …)
•
Personal computers
(first 1974, Altair 8800 …)
•
Supercomputers
•
Clusters
•
Cloud computing
•
… watches?
25
https://en.wikipedia.org/wiki/File:IBM_Blue_Gene_P_supercomputer.jpg
WHAT WAS A COMPUTER?
PA
RT
O
F
TH
IS
IS
A
RE
VI
EW
FR
O
M
O
P1
!
•
TIME TO DISCUSS!
•
Write all the common elements you have seen from the examples
•
Add all the ESSENTIAL characteristic you can think of a modern
COMPUTER
•
YOU HAVE 2 minutes! We will discuss after :)
26
A
RE
VI
art 2
EW
FR
O
M
O
P1
!
WHAT’S INSIDE?
COMPUTER
ARCHITECTURE
27
QUESTION TIME!
OR INSIDE/OUTSIDE OF THE BOX…
•
Think about the following questions:
•
What’s inside the or outside the computer?
•
Can you name all the I/O? What about one that starts
with ne…
•
What is an ISA? What kind fo ISA do you remember?
What is ARC? Where is it used?
28
A
RE
VI
EW
FR
O
FROM NOW ON…
M
O
P1
!
•
•
Computer organisation
•
I/O
•
Memory
•
CPU
Concept of layers and Operating systems…
29
A
RE
VI
EW
FR
O
VON NEUMANN ARCHITECTURE
M
•
Monitor, printer (O)
•
HD,CD, DVD (I/O or
I)
LOGIC UNIT/
DATAPATH
IN
Device
OUT
Device
BUS
Network (I/O)
MEMORY
Stores data and program
Memory
•
!
Mouse, keyboards (I)
•
•
CONTROL
Input/Output (I/O)
•
P1
•
O
CPU
DDR RAM/SRAM
etc…
30
A
RE
VI
EW
FR
O
VON NEUMANN ARCHITECTURE
M
!
•
•
CONTROL
Processor (CPU)
•
P1
•
O
CPU
Datapath: Operative
IN
part, collection of
functional unit such as
ALU (arithmetic logic Device
BUS
unit), process data
Control: Program
counter & registers
LOGIC UNIT/
DATAPATH
Device
MEMORY
Stores data and program
BUS: connect and carry
data (a mean of
communication)
31
OUT
A
RE
EW
FR
O
M
O
P1
(I’LL TELL YOU)
VI
WHAT MORE IS INSIDE OUR “BOX”?
!
•
More I/O (input/output)
•
•
•
Mouse/keyboard
(mousepad, trackpad, etc…
all “I”, cameras, etc…)
Video unit (visual feedback,
“O”)
32
“In the box”:
•
Power supply
•
Motherboard (with CPU)
•
Video card (sometime video
processors are embedded with CPU)
•
Temporary Memory (RAM)
•
Storage Memory (disk)
•
Extra extension (card reader? Extra
bus usb)
•
USB devices
A
RE
VI
EW
FR
O
INPUT (I)/OUTPUT (O)
M
O
P1
!
Mouse
•
Optical/laser
•
Mechanical
•
•
Video
•
LCD (Liquid Crystal Display
+ LEDs), Refresh: 60Hz+
•
CRT (old monitors Cathode
Ray Tube), Refresh: 60Hz+
•
E-INK, Refresh: on demand
(<1Hz)
Touchpad (multitouch?)
•
Keyboard
•
Webcam
•
Most of them has some kind of polling system (usb,
serial etc…)
to check the status
1Hz (hertz) = one cycle per second
•
https://en.wikipedia.org/wiki/File:Delux_M618_vertical_mouse.jpg
https://en.wikipedia.org/wiki/File:Razer_Naga_2014_MMO_Gaming_Mouse_(14714867599).jpg
33
https://commons.wikimedia.org/wiki/File:Webcam_Vivanco_Pro_USB_Voip.jpg
https://commons.wikimedia.org/wiki/File:ProjectionKeyboard_2.jpg
https://www.allekabels.nl/nieuwe-producten/7184/1230154/tastaturen.html?gclid=EAIaIQobChMI4PKE08eN6AIVhuN3Ch0wYw6NEAQYASABEgIkivD_BwE
MEMORY (I/O)
•
From the slowest
•
•
Permanent
•
Disks (floppy?, Hard disks…)
•
SSD (solid state drive)
Volatile
•
RAM
(random access memory,
integrated circuits)
•
CACHE (internal memory, low level)
34
WE SAID NETWORK…
A BRIEF INTRODUCTION
•
•
Hardware:
•
Connector (RJ45)
•
Cables (ethernet)
•
WiFi module
Software:
•
•
Address (192.168.0.1)
80/
0
8
:
m
o
omain.c
Port (8080)
proxy.d
35
F
UF
T
S
_
T
E
SECR
CPU: MADE OF…
•
A lot of things…
•
This is a Core i7-980X
1,17 billions of transistor in 1,6cm2
36
https://tweakers.net/reviews/1585/3/intel-core-i7-980x-een-zeskoppig-monster-gulftown-details.html
CPU
JUS T A SMALL OVERVIEW
•
CPU (central processing unit)
•
Execute the instructions of the
instruction set architecture
(ISA, https://en.wikipedia.org/wiki/
Instruction_set_architecture)
•
•
Each processor has an ISA
•
Not all the machine share the same ISA
With the ISA we can write programs
(actually the compilers do that for us!).
https://en.wikipedia.org/wiki/Instruction_set_architecture
37
https://www.pxfuel.com/en/free-photo-erqmn
ISA
SOME MORE INFO…
•
The ISA is the encoding/implementation of how the CPU will interpret the machine
code you feed.
•
The set of all the possible commands and their behaviour that are encoded in your
hardware
•
Within this there are:
•
Data types
•
Registers
•
Memory management
•
Fundamental features
•
etc…
THE ISA IS SIMILAR WITHIN FAMILIES OF PROCESSORS!
BUT NOT THE SAME!
38
CPU FAMILIES
ALL HAPPY FAMILIES EVOLVE OVER TIME…
•
Different architectures —> different ISA
•
CISC (Complex instruction set computing)
•
•
IBM 370/168 (1970), VAX 11/780 (1977),
X86 (80486, 1989),
RISC (reduced instruction set computer)
•
ARM (Advanced RISC Machine), AVR (Modified Harvard
Architecture), MIPS (Microprocessor without Interlocked
Pipeline Stages), ARC (Argonaut Technology Limited),PIC
(Programmable Intelligent Computer)
39
THESE ARE ALL ARMS!
JUS T AN EXAMPLE…
•
Raspberry pi
•
Most Qualcom processors (snapdragon in most phones)
•
iPhones A*(A7, A8, A10) processor is a derivative of ARM in 32 or
64 bits
•
The M1
is an ARM TOO!
https://upload.wikimedia.org/wikipedia/commons/c/c2/RPi-Logo-SCREEN.png
40
https://www.apple.com
QUESTION TIME!
OR INSIDE/OUTSIDE OF THE BOX…
•
What’s inside the or outside the computer?
•
Can you name all the I/O? What about one that starts
with ne…
•
What is an ISA? What kind fo ISA do you remember?
What is ARC? Where is it used?
41
WHAT’S ON TOP
42
QUESTION TIME!
OR INSIDE/OUTSIDE OF THE BOX…
•
Think about the following questions:
•
What is the meaning of Abstraction?
•
How does it apply to OS?
•
Where is the ISA in this concept?
•
Which are the pro/con of virtualisation?
43
CONCEPT OF LAYERS
•
As you have seen in computer science everything is based on
abstraction, same for the hardware and software
•
We find the concept of layers/levels in all HW/SW projects
•
Abstraction allows you to ignore details and use “objects” as
black boxes
•
Each CPU interprets a predetermined ISA and saves data in
memory but not everyone needs to know how it is implemented in
the electronics
44
ISA: instruction set architecture
A MATTER OF S TEPS…
EXAMPLE
THE C AR ABS TRACTION
•
To recognise a car: you need to know how it shaped (more or less)
•
You don’t need to know how each part is made to recognise
and use it.
•
You don’t need to know how an engine is working to use it.
•
•
There are clear interfaces to use, mount, recognise.
You need to know all those things to fix it or build one.
45
•
Lower levels …
more
informations, less
abstraction,
more details
API
LIBRARIES/UTILITIES
OPERATING SYSTEM
ISA
EXECUTION HARDWARE
MEMORY
TRANSLATION
BUS
I/O DEVICES
AND
NETWORKING
46
MAIN
MEMORY
}
}
Software
Higher levels …
less informations,
more
abstraction, less
details
ABSTRACTION
•
APPLICATION PROGRAMS
Hardware
MORE ABOUT LAYERS
HIGHEST LEVEL OF ABSTRACTION
•
OS virtualisation:
•
Virtual machines
•
Virtual services
•
Cloud computing
47
https://www.virtualbox.org/wiki/Downloads
https://www.vmware.com/
HIGHEST LEVEL OF ABSTRACTION
Advantages of a virtual machine
include:
•
Multiple operating systems
on a single physical computer
without any intervention.
•
Widely available and easy to
manage and maintain.
•
Drawbacks of virtual machines
include:
Offers quick disaster recovery
options
48
•
Not as efficient as a physical
computer because the
hardware resources are
distributed in an indirect way.
•
Multiple VMs on a single
physical machine can deliver
unstable performance.
SUMMARY
WHAT DID WE TALK ABOUT TODAY
•
A bit of history of computers
•
What is the structure of a modern computer
•
Which are the parts that compose a computer and how they
communicate with each other
•
What is the architecture of a computer hardware and software
(we will call this Operating System)
49
QUESTION TIME!
OR INSIDE/OUTSIDE OF THE BOX…
•
Think about the following questions:
•
What is the meaning of Abstraction?
•
How does it apply to OS?
•
Where is the ISA in this concept?
•
Which are the pro/con of virtualisation?
50
LET’S INTRODUCE SOMETHING…
BASH SCRIPTING
51
IN YOUR FINAL
ASSIGNMENT
WE USE
BASH!
(SUCCESSOR OF BOURNE SHELL: SH, IN SOME DISTRIBUTION
SH REPRESENT DASH, ANOTHER KIND OF IMPLEMENTATION
OF BOURN SHELL.)
52
“
> echo "Hello World"
— hello world in bash
”
53
WHY BASH?
BEC AUSE IT IS USEFUL EVERYWHERE!
•
There are many operating systems:
•
•
Windows*, Unix, Linux*, Mac OS, others… (HAIKU, Irix, MSDOS, iOS, …)
Which are the most
distributed?
•
Among
75.000.000
Servers
S E RV E R S I N T H E WO R L D
Unix, Unix-like
Source
Microsoft
Windows
Date
All
W3Techs
Feb 2015
Security
Space
Feb 2014
W3Cook
May 2015
68%
Linux
36%
<79.3%
98%
FreeBSD
1%
Unknown
31%
>20.7%
N/A
97%
https://en.wikipedia.org/wiki/Usage_share_of_operating_systems
https://en.wikipedia.org/wiki/List_of_operating_systems
54
2%
32%
0%
2%
AND WHICH OF THOSE OS HAVE BASH…
OR A COMPATIBLE SHELL SYS TEM?
•
OS from before:
•
•
Windows*, Unix, Linux*, Mac OS, others… (HAIKU, Irix,
MS-DOS, iOS, …)
Almost all the OS have a compatible shell
•
Even Windows?
•
Install: Windows subsystem for Linux (Windows features)
•
…alternatively: Powershell (partially compatible)
*All the red OSs support directly or indirectly a shell compatible with bash (or bash itself)
Windows developed a standard virtualisation system to install linux without changing anything.
55
BASH IS NEEDED
FOR ALL SORT OF THINGS!
•
.net commands require a shell…
•
Server configurations and connections
•
Server automation
•
Essential for web development (never seen VS Code?)
•
Writing programs (quick and dirty, yes more than python)
•
It is the default shell (for users)
•
Make your computer explode…
56
BASH
THIS IS HOW IT LOOKS…
57
WHAT CAN WE DO:
WE C AN , WE WILL… MAYBE.
•
In Python:
from collections import defaultdict
from string import punctuation
wordcount = defaultdict(int)
for line in open('hamlet.txt'):
line = ''.join([char for char in line.lower()
if char not in punctuation])
for word in line.split():
wordcount[word] += 1
for key in sorted(wordcount, key=wordcount.get, reverse=True)[:10]:
print(key, wordcount[key])
•
In Bash:
tr A-Z a-z < hamlet.txt | tr -sc a-z ‘\n’ | sort |
uniq -c | sort -rn | head
Source: “The Unix Programming Environment” by Rob Pike.
58
OPTIONAL EXERCISE
ACTIVIT Y IN CL ASS (ADVANCED)
•
try to understand what the previous command does:
•
Look up the Linux tools tr, sort, uniq, and head
(check the options!).
•
Look up what is the “|” in between those commands.
•
If you did not, install a shell system on your computer to test
out the command.
tr A-Z a-z < hamlet.txt | tr -sc a-z ‘\n’ |
sort | uniq -c | sort -rn | head
59
PARTIAL SOLUTION…
WE WILL LEARN ALL OF THIS IN THE NEXT WEEKS!
•
It is not important to understand all the details, just yet.
•
Only the general idea on how it works and the power and
versatility of the commands are important!
•
If there is no time in class: do it at home. This content will be
introduced step by step later on
•
more examples here
https://linuxhint.com/30_bash_script_examples/
THE CODE WE HAVE SEEN IS A REASONABLE SOLUTION IN PYTHON, WHICH REMOVES PUNCTATION SUCH
THAT “HAMLET” AND “HAMLET.” ARE CONSIDERED THE SAME WORD, AND AFTER THAT THE BASH VERSION
60
THAT’S IT FOR TODAY
IT WASN’T THAT DIFFICULT…
•
Right? :P
•
Do NOT FORGET TO FOLLOW THE GUIDE TO INSTALL THE VM!
We will talk about the virtual machine and more fun next lesson.
•
YOU MUST DOWNLOAD AND INSTALL THE VM BEFORE THE
NEXT LESSON!
61
WHERE ARE WE NOW?
•
The real challenge becomes PARALLEL COMPUTING!
62
https://github.com/karlrupp/microprocessor-trend-data
GROWTH AND MOORE LAW (OPTIONAL)
Download