SlideShare a Scribd company logo
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)

More Related Content

What's hot

Spiral model presentation
Spiral model presentationSpiral model presentation
Spiral model presentation
SayedFarhan110
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
nicky_walters
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
Mukesh Chinta
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
Sweetestangel Kochar
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
InteX Research Lab
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
CS_GDRCST
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basics
Deepak John
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
Baskarkncet
 
Structure
StructureStructure
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
Paras Patel
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
Vetukurivenkatashiva
 
software engineering
software engineeringsoftware engineering
software engineering
Azad public school
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
India
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
Manish Kumar
 
Context Switching
Context SwitchingContext Switching
Context Switching
franksvalli
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 

What's hot (20)

Spiral model presentation
Spiral model presentationSpiral model presentation
Spiral model presentation
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basics
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Structure
StructureStructure
Structure
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
 
software engineering
software engineeringsoftware engineering
software engineering
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Instruction format
Instruction formatInstruction format
Instruction format
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Context Switching
Context SwitchingContext Switching
Context Switching
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 

Similar to 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.pptx
gaafergoda
 
unit-i.pdf
unit-i.pdfunit-i.pdf
unit-i.pdf
RISHI643981
 
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
mary_ramsay
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
DiptoRoy21
 
Process
ProcessProcess
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 2
HectorFabianPintoOsp
 
COA-Unit-1-Basics.ppt
COA-Unit-1-Basics.pptCOA-Unit-1-Basics.ppt
COA-Unit-1-Basics.ppt
Ruhul Amin
 
DLD1.pdf
DLD1.pdfDLD1.pdf
DLD1.pdf
ssuser536c36
 
Spr ch-01
Spr ch-01Spr ch-01
Spr ch-01
Vasim Pathan
 
COMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTESCOMPUTER ORGNAIZATION NOTES
COMPUTER ORGNAIZATION NOTES
Dr.MAYA NAYAK
 
Running a Program.pdf
Running a Program.pdfRunning a Program.pdf
Running a Program.pdf
RodelJoeSmith1
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
Kumar
 
Basic structure of computers
Basic structure of computersBasic structure of computers
Basic structure of computers
Kumar
 
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
dilshad begum
 
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaabms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
bms_complete_co_ppt.aaaaaaaaaaaaaaaaaaaaa
arshadahmedkkp
 
Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013Cs2253 coa-2marks-2013
Cs2253 coa-2marks-2013
Buvana Buvana
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
melbruce90096
 
SDD Translation
SDD  TranslationSDD  Translation
SDD Translation
gavhays
 

Similar to 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)