SlideShare une entreprise Scribd logo
1  sur  15
PROGRAM EXECUTION
BASIC FLOW OF COMPILATION
When a programmer writes code in any language say
c/c++/python this code is called source code.
But,computer dont understand this,it understands only
binary language i.e machine language.so this source code
have to be converted into binary form.the software used
for this is called translation software.
Source
code
Binary
form
execution
TYPES OF TRANSLATION SOFTWARE
COMPILER
INTERPRETER
COMPILER
Compiler takes the complete source code and it
will convert it into machine code at once.
Steps in compilation-:
1)Preprocessing 2)compilation 3)Assembly
4)Linking
Preprocessing Phase-
- removes comments
- Imports all the modules
- Carries out all the preprocessing directives.
Compilation Phase-
1.)analysis Phase-
-smallest indivisible unit in a program is called
token...eg.keywords,identifiers,literals.
-This phase recognizes all the tokens ,and creates a
symbol table out of it.
 Synthesis Phase-
==Syntax tree is a tree that represents all the constructs of the source code in
the form of a tree.
==Basically all the operators are placed on the root node and the operands
are placed on the leaf nodes.
==This phase generates this syntax tree.
==If any error is there ,it will be reported as error.
Once the code is error free,it is converted into assemby language code called
Intermediate code.
Eg-:4*5+9
*
+
9
4
5
 Assembly Phase-
This phase converts the assembly level instructions to equivalent
machine code called object code
 Linking-all the required libraries are loaded with the help of
Linker.
 Loader-It is a part of compiler that loads all the instruction
into memory for execution.
COMPLETE COMPILATION PROCESS
assembly machine
Source
code
analy
sis
synth
esis
Object
code
libraries Executable
INTERPRETATION PROCESS
==It analyses each line of code ,converts it into object code ,adds
required libraries and runs it.
==The first line of code is executed ,yet before second line of
code is converted to object code.
WORKING OF INTERPRETER
code1
code2
code3 interpreter
10101010
10101101
10110110
DIFFERENCE BETWEEN COMPILER AND INTERPRETER
• COMPILER INTERPRETER
• takes entire program - takes single line of code
•
generates intermediate code - does not generate
takes more memory - takes less memory
displays the list of errors - display error in single line
no,once the work is done,it - always required
is no more required
INPUT
OUTPUT
MEMORY
ERRORS
Always
required
ROLE OF OPERATING SYSTEM IN RUNNING A PROGRAM
• OS as a resource manager-
A program when not running lies on the disk.
To execute it,is loaded into memory then it becomes process
==To manage resources(to improve efficiency)
==When a running process needs I/O ,then CPU sits idle ,at that
moment,another process is loaded into memory to improve
efficiency.. Called throughput
THROUGHPUT =
Time taken
NO.of job
completed
To mange multiple functions OS provides following
functions
Process Management-
Once the program is loaded into memory it becomes process.and it is
allocated memory as shown below
Stack
Heap
Global
variables
Program
code
Area used for function
calls,arguments etc
Area used for dynamic
allocation of memory
Comiled code and global
variables are stored here
State diagram of a process
START-when the process first loaded into memory
READY-when the process ready for the CPU to be allocated
RUNNING-when the process is allocated CPU
WAITING-when the process have to wait for some I/O,file etc. It
is put in the waiting queue.When the CPU is available it is
again put in running state
TERMINATED-when the process finishes execution.
start ready running terminated
wait
• PCB-process control block.
It is the datastructure to manage process
stores unique identification number
current state i.e ready,running
details of subprocesses
access privileges of the process
stores the address of the next instructions
stores information about various cpu registers
Process id
state
Pointer
priority
registers
Program
counter
Program execution
1.)Program is loaded into memory
2.)fetch the instructions-CU brings first instruction into
memory
3.)decode the instruction-all the mathematical ,I/O,any logical
work is done.
4.)execute the instruction-ALU carries out the mathematical
work
5.)store the result
6)Fetch the next instruction
Process scheduling
When there are a lot of processes in memory ,computer have to
schedule all the jobs to make the efficient utilisation of CPU called
scheduling.
Types of CPU Scheduling-
1.)FCFS-In this the process which arrives first is allocated the cpu first
2.)SJF-CPU picks the next job that will take the shortest time
3.)Round Robin Scheduling-Every process gets fixed equal time to
execute .
MEMORY MANAGEMENT
-keeps track of each and every memory location
-check how much memory is allocated to which process
-decides which process will get memory
-keeps track of the memory that becomes free
Memory allocation schemes
1)Single memory allocation-single running app.
Gets the hold of memory
2.)Partitioned-Primary memory is partitioned,and
the running process is allocated one partition
3.Paged memory allocation-memory is divided into
fixed sized units called pages.process is loaded
into pages
4.)Segmented memory allocation-memory is
divided logically into fixed segments .They may
not be contigous.
I/O management
• The role of i/O manager of OS is to connect
the process to actual I/O device through some
stratergy.
• The I/O manager sends the request to physical
device and upon receiving response ,it passes
it to the process
Thanking You
Shaifali saini
PGT(CS)

Contenu connexe

Tendances

Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.MOHIT DADU
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loadersTech_MX
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
Command line arguments
Command line argumentsCommand line arguments
Command line argumentsAshok Raj
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.Ravi Kumar Patel
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentationusmankiyani1
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming ) Adarsh Patel
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computingVajira Thambawita
 

Tendances (20)

Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSOR
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Memory management
Memory managementMemory management
Memory management
 
The process states
The process statesThe process states
The process states
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
CPU Scheduling in OS Presentation
CPU Scheduling in OS  PresentationCPU Scheduling in OS  Presentation
CPU Scheduling in OS Presentation
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Batch operating system
Batch operating system Batch operating system
Batch operating system
 

Similaire à Program execution

module 1 computer architecture diploma
 module 1 computer architecture diploma   module 1 computer architecture diploma
module 1 computer architecture diploma Manoharan Ragavan
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
The role of the cpu in the operation
The role of the cpu in the operationThe role of the cpu in the operation
The role of the cpu in the operationmary_ramsay
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2HectorFabianPintoOsp
 
COA-Unit-1-Basics.ppt
COA-Unit-1-Basics.pptCOA-Unit-1-Basics.ppt
COA-Unit-1-Basics.pptRuhul Amin
 
COMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTESCOMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTESDr.MAYA NAYAK
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computersKumar
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computersKumar
 
Ise iv-computer organization [10 cs46]-notes new
Ise iv-computer  organization [10 cs46]-notes newIse iv-computer  organization [10 cs46]-notes new
Ise iv-computer organization [10 cs46]-notes newdilshad begum
 
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaabms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaaarshadahmedkkp
 
Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013Buvana Buvana
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxmelbruce90096
 
SDD Translation
SDD  TranslationSDD  Translation
SDD Translationgavhays
 

Similaire à Program execution (20)

module 1 computer architecture diploma
 module 1 computer architecture diploma   module 1 computer architecture diploma
module 1 computer architecture diploma
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
unit-i.pdf
unit-i.pdfunit-i.pdf
unit-i.pdf
 
The role of the cpu in the operation
The role of the cpu in the operationThe role of the cpu in the operation
The role of the cpu in the operation
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Process
ProcessProcess
Process
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
 
COA-Unit-1-Basics.ppt
COA-Unit-1-Basics.pptCOA-Unit-1-Basics.ppt
COA-Unit-1-Basics.ppt
 
DLD1.pdf
DLD1.pdfDLD1.pdf
DLD1.pdf
 
Spr ch-01
Spr ch-01Spr ch-01
Spr ch-01
 
COMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTESCOMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTES
 
Running a Program.pdf
Running a Program.pdfRunning a Program.pdf
Running a Program.pdf
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
 
Ise iv-computer organization [10 cs46]-notes new
Ise iv-computer  organization [10 cs46]-notes newIse iv-computer  organization [10 cs46]-notes new
Ise iv-computer organization [10 cs46]-notes new
 
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaabms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
 
Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
 
SDD Translation
SDD  TranslationSDD  Translation
SDD Translation
 

Program execution

  • 1. PROGRAM EXECUTION BASIC FLOW OF COMPILATION When a programmer writes code in any language say c/c++/python this code is called source code. But,computer dont understand this,it understands only binary language i.e machine language.so this source code have to be converted into binary form.the software used for this is called translation software. Source code Binary form execution
  • 2. TYPES OF TRANSLATION SOFTWARE COMPILER INTERPRETER COMPILER Compiler takes the complete source code and it will convert it into machine code at once. Steps in compilation-: 1)Preprocessing 2)compilation 3)Assembly 4)Linking
  • 3. Preprocessing Phase- - removes comments - Imports all the modules - Carries out all the preprocessing directives. Compilation Phase- 1.)analysis Phase- -smallest indivisible unit in a program is called token...eg.keywords,identifiers,literals. -This phase recognizes all the tokens ,and creates a symbol table out of it.
  • 4.  Synthesis Phase- ==Syntax tree is a tree that represents all the constructs of the source code in the form of a tree. ==Basically all the operators are placed on the root node and the operands are placed on the leaf nodes. ==This phase generates this syntax tree. ==If any error is there ,it will be reported as error. Once the code is error free,it is converted into assemby language code called Intermediate code. Eg-:4*5+9 * + 9 4 5
  • 5.  Assembly Phase- This phase converts the assembly level instructions to equivalent machine code called object code  Linking-all the required libraries are loaded with the help of Linker.  Loader-It is a part of compiler that loads all the instruction into memory for execution. COMPLETE COMPILATION PROCESS assembly machine Source code analy sis synth esis Object code libraries Executable
  • 6. INTERPRETATION PROCESS ==It analyses each line of code ,converts it into object code ,adds required libraries and runs it. ==The first line of code is executed ,yet before second line of code is converted to object code. WORKING OF INTERPRETER code1 code2 code3 interpreter 10101010 10101101 10110110
  • 7. DIFFERENCE BETWEEN COMPILER AND INTERPRETER • COMPILER INTERPRETER • takes entire program - takes single line of code • generates intermediate code - does not generate takes more memory - takes less memory displays the list of errors - display error in single line no,once the work is done,it - always required is no more required INPUT OUTPUT MEMORY ERRORS Always required
  • 8. ROLE OF OPERATING SYSTEM IN RUNNING A PROGRAM • OS as a resource manager- A program when not running lies on the disk. To execute it,is loaded into memory then it becomes process ==To manage resources(to improve efficiency) ==When a running process needs I/O ,then CPU sits idle ,at that moment,another process is loaded into memory to improve efficiency.. Called throughput THROUGHPUT = Time taken NO.of job completed
  • 9. To mange multiple functions OS provides following functions Process Management- Once the program is loaded into memory it becomes process.and it is allocated memory as shown below Stack Heap Global variables Program code Area used for function calls,arguments etc Area used for dynamic allocation of memory Comiled code and global variables are stored here
  • 10. State diagram of a process START-when the process first loaded into memory READY-when the process ready for the CPU to be allocated RUNNING-when the process is allocated CPU WAITING-when the process have to wait for some I/O,file etc. It is put in the waiting queue.When the CPU is available it is again put in running state TERMINATED-when the process finishes execution. start ready running terminated wait
  • 11. • PCB-process control block. It is the datastructure to manage process stores unique identification number current state i.e ready,running details of subprocesses access privileges of the process stores the address of the next instructions stores information about various cpu registers Process id state Pointer priority registers Program counter
  • 12. Program execution 1.)Program is loaded into memory 2.)fetch the instructions-CU brings first instruction into memory 3.)decode the instruction-all the mathematical ,I/O,any logical work is done. 4.)execute the instruction-ALU carries out the mathematical work 5.)store the result 6)Fetch the next instruction
  • 13. Process scheduling When there are a lot of processes in memory ,computer have to schedule all the jobs to make the efficient utilisation of CPU called scheduling. Types of CPU Scheduling- 1.)FCFS-In this the process which arrives first is allocated the cpu first 2.)SJF-CPU picks the next job that will take the shortest time 3.)Round Robin Scheduling-Every process gets fixed equal time to execute . MEMORY MANAGEMENT -keeps track of each and every memory location -check how much memory is allocated to which process -decides which process will get memory -keeps track of the memory that becomes free
  • 14. Memory allocation schemes 1)Single memory allocation-single running app. Gets the hold of memory 2.)Partitioned-Primary memory is partitioned,and the running process is allocated one partition 3.Paged memory allocation-memory is divided into fixed sized units called pages.process is loaded into pages 4.)Segmented memory allocation-memory is divided logically into fixed segments .They may not be contigous.
  • 15. I/O management • The role of i/O manager of OS is to connect the process to actual I/O device through some stratergy. • The I/O manager sends the request to physical device and upon receiving response ,it passes it to the process Thanking You Shaifali saini PGT(CS)