SlideShare a Scribd company logo
1
KUMO B4 shuya
2
Running Program = Execute Instructions
Many millions of time every second the Processor …

‣ fetches an instruction from memory

‣ decodes it (figure out which instruction it is) 

‣ executes it (it does the thing supposed to do)
A body of Software
‣ Above model is called Von Neumann model of computing

‣ A body of software is called the operating system (OS), it is
in charge of making sure system operates in an easy-to-use
I made 

Computer !
3
Virtualization, Primary way the OS manage resources
‣ OS takes resources and transforms it into a virtual form of itself.
‣ We call the technique virtualization.

‣ OS allows users to use virtual machine through system calls.

‣ Also saying that OS provides a standard library to applications.
OS is a resource manager
‣ Each of CPU, memory, disk is a resource of the system; it is 

thus operating system’s role to manage those resources
4
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"
int
main (int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, "usage: cpu <string>n");
exit(1);
}
char *str = argv[1];
while (1) {
Spin(1);
printf("%sn", str);
}
return 0;
}
[~/dev/kumo/OSTEP/src/chapter2]
$ gcc -o cpu cpu.c -Wall
$ ./cpu "A"
A
A
A
^C
$ ./cpu A &; ./cpu B &; ./cpu C &; ./cpu D &
[1] 4285
[2] 4286
[3] 4287
[4] 4288
[~/dev/kumo/OSTEP/src/chapter2]
$ A 

B
C
D
A
B
C
D
A
Code Outputs
5
[~/dev/kumo/OSTEP/src/chapter2]
$ gcc -o cpu cpu.c -Wall
$ ./cpu "A"
A
A
A
^C
$ ./cpu A &; ./cpu B &; ./cpu C &; ./cpu D &
[1] 4285
[2] 4286
[3] 4287
[4] 4288
[~/dev/kumo/OSTEP/src/chapter2]
$ A 

B
C
D
A
B
C
D
A
We have one processor but…
‣ It turns out that the system has 

large number virtual CPUs.

‣ When did two programs want to
run at a particular time, 

which should run?

-> It depends on a policy of the OS.
6
Physical memory is very simple
Memory is just an array of bytes

‣ To read memory specify an address to be able to access the
data stored there. 

‣ To write memory, also specify the data to be written to the
given address.

‣ Memory accessed all the time when a program is running.
7
‣ It points out the address of me-
mory and the process identifier.

‣ The newly allocated memory is at
0x7f9ba04002e0.
$ ./mem
(5828) address pointed to by p: 0x7f9ba04002e0
(5828) p: 1
(5828) p: 2
(5828) p: 3
Result1 - single memory space
$ ./mem & ; ./mem & ;
[1] 5433
[2] 5434
(5433) address pointed to by p: 0x7f96944002a0
(5434) address pointed to by p: 0x7fb1ca4002e0

$ (5433) p: 1
(5434) p: 1
(5433) p: 2
(5434) p: 2
‣ Allocated same address 

‣ Each program update the value,

virtual address space make it
possible.
Result2 - virtualizing memory
8
A multi thread program
‣ Create two threads using
Pthread_create( )

‣ Each thread starts running in a routine
called worker( )
‣ The value of loops determines how
many times each of the two workers
will increment the shared counter in a
loop.
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
volatile int counter = 0;
int loops;
void *worker (void * arg) {
int i;
for (i= 0; i < loops; i++) {
counter++;
}
return NULL;
}
int
main (int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, "usage: threads
<value>n");
exit(1);
}
loops = atoi(argv[1]);
pthread_t p1, p2;
printf("Initial value : %dn", counter);
Pthread_create(&p1, NULL, worker, NULL);
Pthread_create(&p2, NULL, worker, NULL);
Pthread_join(p1, NULL);
Pthread_join(p2, NULL);
printf("Final value : %dn", counter);
return 0;
}
9
‣ When the input value of loops is
set to N, final output to be 2N.
$ ./threads 1000
Initial value : 0
Final value : 2000
Result1
$ ./threads 100000
Initial value : 0
Final value : 112807
$ ./threads 100000
Initial value : 0
Final value : 118738
‣ The program takes three instructions;

load, increments, store.

‣ These instructions don’t execute
atomically, strange things can happen.

‣ It is this problem of concurrency.
Result2 - higher values
10
Needed to be able to store data persistency
‣ Such as DRAM store values in a volatile manner, when the
power goes away or the system crashes any data in memory
is lost. So persistence is important.

‣ The hardware comes in the form of input/output or I/O
devices, a hard drive is a repository for long-lived information.

‣ File system; it is responsible for storing any files.

‣ System calls are routed to the part of the operating system
called file system.
11
Finding the right set of trade-off is a key
‣ Abstractions 

-> It is fundamental to everything we do in CS. Abstraction is 

a technique for arranging complexity of computer systems.

‣ Performance 

-> This can paraphrase to minimize the overheads. 

Virtualization makes the system easy to use.

‣ Protection

-> Isolating process from one another is key to protection.

‣ Reliability

-> The OS must run non-stop.

More Related Content

What's hot

Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
Scheduling in Linux and Web Servers
Scheduling in Linux and Web ServersScheduling in Linux and Web Servers
Scheduling in Linux and Web ServersDavid Evans
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in RustInfluxData
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationrjsmelo
 
Smarter Scheduling
Smarter SchedulingSmarter Scheduling
Smarter SchedulingDavid Evans
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in backgroundDr. Girish GS
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queueBrandon Lamb
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers ToolboxStefan
 
Thinking in Sequences - Streams in Node.js & IO.js
Thinking in Sequences - Streams in Node.js & IO.jsThinking in Sequences - Streams in Node.js & IO.js
Thinking in Sequences - Streams in Node.js & IO.jsArtur Skowroński
 
Device-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded SystemsDevice-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded SystemsemBO_Conference
 
(Practical) linux 104
(Practical) linux 104(Practical) linux 104
(Practical) linux 104Arie Bregman
 
Trelles_QnormBOSC2009
Trelles_QnormBOSC2009Trelles_QnormBOSC2009
Trelles_QnormBOSC2009bosc
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scriptingDan Morrill
 
(Practical) linux 101
(Practical) linux 101(Practical) linux 101
(Practical) linux 101Arie Bregman
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingDan Morrill
 
Making a Process
Making a ProcessMaking a Process
Making a ProcessDavid Evans
 
Ntp cheat sheet
Ntp cheat sheetNtp cheat sheet
Ntp cheat sheetcsystemltd
 

What's hot (20)

Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Scheduling in Linux and Web Servers
Scheduling in Linux and Web ServersScheduling in Linux and Web Servers
Scheduling in Linux and Web Servers
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
 
test questions
test questionstest questions
test questions
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 
Smarter Scheduling
Smarter SchedulingSmarter Scheduling
Smarter Scheduling
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queue
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
Thinking in Sequences - Streams in Node.js & IO.js
Thinking in Sequences - Streams in Node.js & IO.jsThinking in Sequences - Streams in Node.js & IO.js
Thinking in Sequences - Streams in Node.js & IO.js
 
Device-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded SystemsDevice-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded Systems
 
(Practical) linux 104
(Practical) linux 104(Practical) linux 104
(Practical) linux 104
 
Trelles_QnormBOSC2009
Trelles_QnormBOSC2009Trelles_QnormBOSC2009
Trelles_QnormBOSC2009
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
(Practical) linux 101
(Practical) linux 101(Practical) linux 101
(Practical) linux 101
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
Making a Process
Making a ProcessMaking a Process
Making a Process
 
Ntp cheat sheet
Ntp cheat sheetNtp cheat sheet
Ntp cheat sheet
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 

Similar to OSTEP Chapter2 Introduction

Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005dflexer
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlabMuhammad Alli
 
Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)Julien SIMON
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8AbdullahMunir32
 
AMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion PassengerAMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion Passengericemobile
 
03. top level view of computer function &amp; interconnection
03. top level view of computer function &amp; interconnection03. top level view of computer function &amp; interconnection
03. top level view of computer function &amp; interconnectionnoman yasin
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdfKadu37
 
Operating system ch#7
Operating system ch#7Operating system ch#7
Operating system ch#7Noor Noon
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming Max Kleiner
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...David Walker
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029marangburu42
 

Similar to OSTEP Chapter2 Introduction (20)

Unix kernal
Unix kernalUnix kernal
Unix kernal
 
Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005
 
Unit2fit
Unit2fitUnit2fit
Unit2fit
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
php & performance
 php & performance php & performance
php & performance
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlab
 
Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)Deep Dive on Amazon EC2 Instances (March 2017)
Deep Dive on Amazon EC2 Instances (March 2017)
 
Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8Parallel and Distributed Computing Chapter 8
Parallel and Distributed Computing Chapter 8
 
AMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion PassengerAMS Node Meetup December presentation Phusion Passenger
AMS Node Meetup December presentation Phusion Passenger
 
03. top level view of computer function &amp; interconnection
03. top level view of computer function &amp; interconnection03. top level view of computer function &amp; interconnection
03. top level view of computer function &amp; interconnection
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
Operating system ch#7
Operating system ch#7Operating system ch#7
Operating system ch#7
 
Parallel computation
Parallel computationParallel computation
Parallel computation
 
Process management
Process managementProcess management
Process management
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029
 
parallel-computation.pdf
parallel-computation.pdfparallel-computation.pdf
parallel-computation.pdf
 

More from Shuya Osaki

第2章 プロトコル
第2章 プロトコル第2章 プロトコル
第2章 プロトコルShuya Osaki
 
公的個人認証サービスを用いたスマートエスクロー
公的個人認証サービスを用いたスマートエスクロー公的個人認証サービスを用いたスマートエスクロー
公的個人認証サービスを用いたスマートエスクローShuya Osaki
 
学部紹介セミナー[森村学園高等部]
学部紹介セミナー[森村学園高等部]学部紹介セミナー[森村学園高等部]
学部紹介セミナー[森村学園高等部]Shuya Osaki
 
Summarized of UNIX Time Sharing System
Summarized of UNIX Time Sharing SystemSummarized of UNIX Time Sharing System
Summarized of UNIX Time Sharing SystemShuya Osaki
 
マスタリングTCP/IP 入門編 1章
マスタリングTCP/IP 入門編 1章マスタリングTCP/IP 入門編 1章
マスタリングTCP/IP 入門編 1章Shuya Osaki
 
Nand2 tetris 1and2
Nand2 tetris 1and2Nand2 tetris 1and2
Nand2 tetris 1and2Shuya Osaki
 
RG_LT大会_SFCで車通学をする
RG_LT大会_SFCで車通学をするRG_LT大会_SFCで車通学をする
RG_LT大会_SFCで車通学をするShuya Osaki
 
Primer to Browser Netwroking
Primer to Browser NetwrokingPrimer to Browser Netwroking
Primer to Browser NetwrokingShuya Osaki
 
How to Upload File in SFC.
How to Upload File in SFC.How to Upload File in SFC.
How to Upload File in SFC.Shuya Osaki
 
How to Use Email in SFC.
How to Use Email in SFC.How to Use Email in SFC.
How to Use Email in SFC.Shuya Osaki
 
自動運転の概要
自動運転の概要自動運転の概要
自動運転の概要Shuya Osaki
 
Introduction to QUIC
Introduction to QUICIntroduction to QUIC
Introduction to QUICShuya Osaki
 
ハイパフォーマンスブラウザネットワーキング2
ハイパフォーマンスブラウザネットワーキング2ハイパフォーマンスブラウザネットワーキング2
ハイパフォーマンスブラウザネットワーキング2Shuya Osaki
 
ハイパフォーマンスブラウザネットワーキング1
ハイパフォーマンスブラウザネットワーキング1ハイパフォーマンスブラウザネットワーキング1
ハイパフォーマンスブラウザネットワーキング1Shuya Osaki
 

More from Shuya Osaki (15)

第2章 プロトコル
第2章 プロトコル第2章 プロトコル
第2章 プロトコル
 
公的個人認証サービスを用いたスマートエスクロー
公的個人認証サービスを用いたスマートエスクロー公的個人認証サービスを用いたスマートエスクロー
公的個人認証サービスを用いたスマートエスクロー
 
学部紹介セミナー[森村学園高等部]
学部紹介セミナー[森村学園高等部]学部紹介セミナー[森村学園高等部]
学部紹介セミナー[森村学園高等部]
 
Summarized of UNIX Time Sharing System
Summarized of UNIX Time Sharing SystemSummarized of UNIX Time Sharing System
Summarized of UNIX Time Sharing System
 
マスタリングTCP/IP 入門編 1章
マスタリングTCP/IP 入門編 1章マスタリングTCP/IP 入門編 1章
マスタリングTCP/IP 入門編 1章
 
Nand2 tetris 1and2
Nand2 tetris 1and2Nand2 tetris 1and2
Nand2 tetris 1and2
 
RG_LT大会_SFCで車通学をする
RG_LT大会_SFCで車通学をするRG_LT大会_SFCで車通学をする
RG_LT大会_SFCで車通学をする
 
RG講義_SSH
RG講義_SSHRG講義_SSH
RG講義_SSH
 
Primer to Browser Netwroking
Primer to Browser NetwrokingPrimer to Browser Netwroking
Primer to Browser Netwroking
 
How to Upload File in SFC.
How to Upload File in SFC.How to Upload File in SFC.
How to Upload File in SFC.
 
How to Use Email in SFC.
How to Use Email in SFC.How to Use Email in SFC.
How to Use Email in SFC.
 
自動運転の概要
自動運転の概要自動運転の概要
自動運転の概要
 
Introduction to QUIC
Introduction to QUICIntroduction to QUIC
Introduction to QUIC
 
ハイパフォーマンスブラウザネットワーキング2
ハイパフォーマンスブラウザネットワーキング2ハイパフォーマンスブラウザネットワーキング2
ハイパフォーマンスブラウザネットワーキング2
 
ハイパフォーマンスブラウザネットワーキング1
ハイパフォーマンスブラウザネットワーキング1ハイパフォーマンスブラウザネットワーキング1
ハイパフォーマンスブラウザネットワーキング1
 

Recently uploaded

Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxShibin Azad
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 

Recently uploaded (20)

Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 

OSTEP Chapter2 Introduction

  • 2. 2 Running Program = Execute Instructions Many millions of time every second the Processor … ‣ fetches an instruction from memory ‣ decodes it (figure out which instruction it is) ‣ executes it (it does the thing supposed to do) A body of Software ‣ Above model is called Von Neumann model of computing ‣ A body of software is called the operating system (OS), it is in charge of making sure system operates in an easy-to-use I made 
 Computer !
  • 3. 3 Virtualization, Primary way the OS manage resources ‣ OS takes resources and transforms it into a virtual form of itself. ‣ We call the technique virtualization. ‣ OS allows users to use virtual machine through system calls. ‣ Also saying that OS provides a standard library to applications. OS is a resource manager ‣ Each of CPU, memory, disk is a resource of the system; it is 
 thus operating system’s role to manage those resources
  • 4. 4 #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <assert.h> #include "common.h" int main (int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "usage: cpu <string>n"); exit(1); } char *str = argv[1]; while (1) { Spin(1); printf("%sn", str); } return 0; } [~/dev/kumo/OSTEP/src/chapter2] $ gcc -o cpu cpu.c -Wall $ ./cpu "A" A A A ^C $ ./cpu A &; ./cpu B &; ./cpu C &; ./cpu D & [1] 4285 [2] 4286 [3] 4287 [4] 4288 [~/dev/kumo/OSTEP/src/chapter2] $ A 
 B C D A B C D A Code Outputs
  • 5. 5 [~/dev/kumo/OSTEP/src/chapter2] $ gcc -o cpu cpu.c -Wall $ ./cpu "A" A A A ^C $ ./cpu A &; ./cpu B &; ./cpu C &; ./cpu D & [1] 4285 [2] 4286 [3] 4287 [4] 4288 [~/dev/kumo/OSTEP/src/chapter2] $ A 
 B C D A B C D A We have one processor but… ‣ It turns out that the system has 
 large number virtual CPUs. ‣ When did two programs want to run at a particular time, 
 which should run? -> It depends on a policy of the OS.
  • 6. 6 Physical memory is very simple Memory is just an array of bytes ‣ To read memory specify an address to be able to access the data stored there. ‣ To write memory, also specify the data to be written to the given address. ‣ Memory accessed all the time when a program is running.
  • 7. 7 ‣ It points out the address of me- mory and the process identifier. ‣ The newly allocated memory is at 0x7f9ba04002e0. $ ./mem (5828) address pointed to by p: 0x7f9ba04002e0 (5828) p: 1 (5828) p: 2 (5828) p: 3 Result1 - single memory space $ ./mem & ; ./mem & ; [1] 5433 [2] 5434 (5433) address pointed to by p: 0x7f96944002a0 (5434) address pointed to by p: 0x7fb1ca4002e0
 $ (5433) p: 1 (5434) p: 1 (5433) p: 2 (5434) p: 2 ‣ Allocated same address ‣ Each program update the value,
 virtual address space make it possible. Result2 - virtualizing memory
  • 8. 8 A multi thread program ‣ Create two threads using Pthread_create( ) ‣ Each thread starts running in a routine called worker( ) ‣ The value of loops determines how many times each of the two workers will increment the shared counter in a loop. #include <stdio.h> #include <stdlib.h> #include "common.h" volatile int counter = 0; int loops; void *worker (void * arg) { int i; for (i= 0; i < loops; i++) { counter++; } return NULL; } int main (int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "usage: threads <value>n"); exit(1); } loops = atoi(argv[1]); pthread_t p1, p2; printf("Initial value : %dn", counter); Pthread_create(&p1, NULL, worker, NULL); Pthread_create(&p2, NULL, worker, NULL); Pthread_join(p1, NULL); Pthread_join(p2, NULL); printf("Final value : %dn", counter); return 0; }
  • 9. 9 ‣ When the input value of loops is set to N, final output to be 2N. $ ./threads 1000 Initial value : 0 Final value : 2000 Result1 $ ./threads 100000 Initial value : 0 Final value : 112807 $ ./threads 100000 Initial value : 0 Final value : 118738 ‣ The program takes three instructions;
 load, increments, store. ‣ These instructions don’t execute atomically, strange things can happen. ‣ It is this problem of concurrency. Result2 - higher values
  • 10. 10 Needed to be able to store data persistency ‣ Such as DRAM store values in a volatile manner, when the power goes away or the system crashes any data in memory is lost. So persistence is important. ‣ The hardware comes in the form of input/output or I/O devices, a hard drive is a repository for long-lived information. ‣ File system; it is responsible for storing any files. ‣ System calls are routed to the part of the operating system called file system.
  • 11. 11 Finding the right set of trade-off is a key ‣ Abstractions 
 -> It is fundamental to everything we do in CS. Abstraction is 
 a technique for arranging complexity of computer systems. ‣ Performance 
 -> This can paraphrase to minimize the overheads. 
 Virtualization makes the system easy to use. ‣ Protection
 -> Isolating process from one another is key to protection. ‣ Reliability
 -> The OS must run non-stop.