INSIGHT INTO PROGRAM EXECUTION
Short Answer Type Questions
Q.1 What are the front end and
back end phases of compiler?
Ans: The front end phase of compiler is Analysis Phase. This phase of compilation identifies all the tokens
in the source code and creates a symbol table with it.
The back end phase of compiler is Synthesis Phase. This phase of compiler
parses the code and generates syntax tree, analyzing the syntax of the source
code. Q.2 Differentiate between compiler and interpreter.
Ans:
Aspects |
Compiler |
Interpreter |
Input |
A
Compiler takes an entire program as its input. |
It takes a single line of
code or single instruction(such as loop) as its input. |
Output |
It
generates intermediate object code from the whole program. |
It does not create any intermediate object code. |
Memory |
Requires more
memory during compilation. |
Requires less memory
during interpretation as interprets single instruction/unit-of-code at a
time. |
Errors |
Displays lists of
errors of entire program with line numbers and the error(s) in that line. |
Displays the error of single line it is interpreting. Thus
errors also appear one line at a time. |
Always Required |
No. once the role of
compiler is over, a compiler is no longer required to run the executable
fuile. |
Always required.
Interpreter translates and runs one instruction every time. So it is always
required in memory to run the code. |
Workload |
Compilation once done,
stays always. Recompilation not required if the code(without any change)
needs to run again. The same executable file can be rerun without the
compiler. |
Interpretation is
required each time you have to run the code. The interpreter does not create
an executable and hence it is required every time, the code is to run. |
Q.3
What are the characteristics
of compiler?
Ans:
Aspects |
Compiler |
Input |
A Compiler takes an entire program as its input. |
Output |
It generates intermediate object code from the whole
program. |
Memory |
Requires more memory during compilation. |
Errors |
Displays lists of errors of entire program with line
numbers and the error(s) in that line. |
Always Required |
No.
once the role of compiler is over, a compiler is no longer required to run
the executable fuile. |
Workload |
Compilation once done, stays always. Recompilation not
required if the code(without any change) needs to run again. The same
executable file can be rerun without the compiler. |
Q.4 What are the
characteristics of Interpreter?
Ans:
Aspects |
Interpreter |
Input |
It takes a single line of code or single
instruction(such as loop) as its input. |
Output |
It does not create any intermediate object code. |
Memory |
Requires
less memory during interpretation as interprets single
instruction/unit-of-code at a time. |
Errors |
Displays the error of single line it is interpreting.
Thus errors also appear one line at a time. |
Always Required |
Always
required. Interpreter translates and runs one instruction every time. So it
is always required in memory to run the code. |
Workload |
Interpretation
is required each time you have to run the code. The interpreter does not
create an executable and hence it is required every time, the code is to run.
|
Q.5 Describe the role of
Operating System as a resource Manager.
Ans: A computer system has many resources (hardware and software),
which may be require to complete a task. The commonly required resources are
input/output devices, memory, file storage space, CPU etc. The operating system
acts as a manager of the above resources and allocates them to specific
programs and users, whenever necessary to perform a particular task. Therefore operating
system is the resource manager i.e. it can manage the resource of a computer
system internally. The resources are processor, memory, files, and I/O devices.
In simple terms, an operating system is the interface between the user and the
machine.
Operating
System Management Tasks
1.
Processor
management which involves putting the tasks into order and pairing them
into manageable size before they go to the CPU.
2.
Memory
management which coordinates data to and from RAM (random-access memory)
and determines the necessity for virtual memory.
3.
Device
management which provides interface between connected devices.
4.
Storage
management which directs permanent data storage.
5.
Application which
allows standard communication between software and your computer.
6.
User interface
which allows you to communicate with your computer. Q.6 What is cloud
computing?
Ans: cloud computing is the delivery of computing services—servers,
storage, databases, networking, software, analytics, intelligence and more—over
the Internet (―the cloud‖) to offer faster innovation, flexible resources and
economies of scale. You typically pay only for cloud services you use, helping
lower your operating costs, run your infrastructure more efficiently and scale
as your business needs change.
Cloud computing is a big shift
from the traditional way businesses think about IT resources.
Here are seven
common reasons organizations are turning to cloud computing services. Q.7 What
are the advantages of parallel computing?
Ans: Parallel computing is a type of computation in which many
calculations or the execution of processes are carried out simultaneously.
Large problems can often be divided into smaller ones, which can then be solved
at the same time. It refers to the simultaneous working of multiple processors
to solve a computational problem. Its advantages are – (i) It saves time and the cost too.
(ii)
It makes easier to solve larger or complex problems.
(iii)
It provides efficient use of underlying hardware.
(iv)
It can utilize the resources available remotely. Q.8
What is the basic flow of program execution?
Ans: the basic flow of program execution can be defined when a
programmer create a program( the source code), which needs to be converted into
binary form so that computer can execute it.
This conversion is done by a software which is known as
translator(compiler or interpreter).
Q.9 What is the difference
between source code and object code?
Ans:
Source Code refers to the
original code written in a programming language by a programmer. Object
Code refers to the code
converted into computer understandable form that a computer can understand and
can directly execute. Q.10 What are the
steps of compilation?
Ans: The compilation mainly undergoes these steps:
(i)
Preprocessing
(ii)
Compilation
a.
Analysis
b.
Synthesis
(iii)
Assembly
(iv)
Linking
Q.11 What is the role of linker in a
compiler?
Ans: The
part of the compiler which performs the linking of libraries is called linker.
In this phase, with the help of OS, all memory references are resolved and code
is converted to a form which requires nothing else to run.that is, the code has
become executable (.exe. file) now. Q.12
How is interpretation done?
Ans: Unlike
compiler, an interpreter doesn‘t translate the complete code in one go and hand
over a full executable file to execute. Instead, an interpreter translates a
single line/section of code at a time, makes its executable version and suns it
immediately. Q.13 How is a process
different from a program?
Ans: A running program or the executing entity is called a process.
So a program is a passive entity when it is stored in storage. When it is
copied to memory to get executed and starts its execution then the program is
known as process.
Q.14
What is
process scheduling?
Ans: The process scheduling is the activity of the process manager
that handles the removal of the running process from the CPU and the selection
of another process on the basis of a particular strategy.
Process scheduling is an essential part of a
Multiprogramming operating systems. Such operating systems allow more than one
process to be loaded into the executable memory at a time and the loaded
process shares the CPU using time multiplexing.
Q.15
What are
process scheduling queues?
Ans: The OS maintains all PCBs in Process Scheduling Queues. The OS
maintains a separate queue for each of the process states and PCBs of all
processes in the same execution state are placed in the same queue. When the
state of a process is changed, its PCB is unlinked from its current queue and
moved to its new state queue.
The Operating
System maintains the following important process scheduling queues − Job queue −
This queue keeps all the processes in the system.
•
Ready queue − This
queue keeps a set of all processes residing in main memory, ready and waiting
to execute. A new process is always put in this queue.
•
Device
queues − The processes which are blocked due to
unavailability of an I/O device constitute this queue.
Q.16 How does OS manage all the running
processes?
Ans:
Process managements involve the execution of various tasks such as creation
of processes, scheduling of processes, management of deadlock, and termination
of processes. It is responsibility of operating system to manage all the
running processes of the system. Operating system manages processes by
performing tasks such as resource allocation and process scheduling. When a
process runs on computer device memory and CPU of computer are utilized. The
operating system also has to synchronize the different processes of computer
system.
A process consists of set of instruction to be
executed called process code. A process is also associated with some data that
is to be processed. The resources that a process required for its execution is
called process components. There is also a state that is associated with a
process at a particular instant of time called process state. Similar to these
concepts, there are number of concepts associated with the process management
function of an operating system. Some of those concepts are given as following.
•
Process State
•
Process Control Block (PCB)
•
Process Operations Process
Scheduling
•
Process Synchronization
•
Interprocess Communication
•
Deadlock
Q.17 What is the role of memory manager and
I/O manager of OS?
Ans: Memory management is a form of resource
management applied
to computer memory. The
essential requirement of memory management is to provide ways to dynamically
allocate portions of memory to programs at their request, and free it for reuse
when no longer needed. This is critical to any advanced computer system where
more than a single process might
be underway at any time.
I/O
Manager:One of the important jobs of an Operating System is to manage
various I/O devices including mouse, keyboards, touch pad, disk drives, display
adapters, USB devices, Bitmapped screen, LED, Analog-to-digital converter,
On/off switch, network connections, audio I/O, printers etc.
An I/O system is required to take an
application I/O request and send it to the physical device, then take whatever
response comes back from the device and send it to the application. I/O devices
can be divided into two categories −
•
Block
devices − A block device is one with which the driver communicates by
sending entire blocks of data. For example, Hard disks, USB cameras,
Disk-On-Key etc.
•
Character
devices − A character device is one with which the driver communicates by
sending and receiving single characters (bytes, octets). For example, serial
ports, parallel ports, sounds cards etc
Q.18
How is
private cloud different from public cloud?
Ans:
Public cloud: Public clouds are
owned and operated by a third-party cloud service
providers, which
deliver their computing resources like servers and storage over the Internet.
Microsoft Azure is an example of a public cloud. With a public cloud, all hardware,
software and other supporting infrastructure is owned and managed by the cloud
provider. You access these services and manage your account using a web
browser.
Private cloud: A private cloud refers
to cloud computing resources used exclusively by a single business or
organization. A private cloud can be physically located on the company‘s
on-site datacenter. Some companies also pay third-party service providers to
host their private cloud. A private cloud is one in which the services and
infrastructure are maintained on a private network.
Q.19
What is
parallel computing?
Ans: Parallel computing is a type of computation in which many
calculations or the execution of processes are carried out simultaneously.
Large problems can often be divided into smaller ones, which can then be solved
at the same time. It refers to the simultaneous working of multiple processors
to solve a computational problem.
Q.20
How is
parallel computing different from serial computing?
Ans: Serial Computing: A
processing in which one task is completed at a time and all the tasks are run
by the processor in a sequence. In real time example, people standing in a
queue and waiting for a railway ticket. In this case, one person can get a
ticket at a time. Suppose there are two queues of people and one cashier is
handling both the queues then one person can get a ticket at a time from both
queues. Similarly, processor get lists of tasks and each task is completed at a
time and all other tasks wait till the first one completes. This type of
processing is also known as sequential
processing.
Parallel Computing: A type of processing
in which multiple tasks are completed at a time by different processors. Note
that in parallel processing there is more than one processor involved. In real
time example, there are multiple queues of people standing to get railway
tickets. In this case, each queue is handled by multiple people, so multiple
people will get tickets at a time. Similarly, in the operating system, there
are multiple queues of tasks and multiple tasks are completed by different
processors at a time.
Q.21
What are the
advantages of parallel computing?
Ans: Parallel computing is a type of computation in which many
calculations or the execution of processes are carried out simultaneously.
Large problems can often be divided into smaller ones, which can then be solved
at the same time. It refers to the simultaneous working of multiple processors
to solve a computational problem. Its advantages are – (i) It saves time and the cost too.
(ii)
It makes easier to solve larger or complex problems.
(iii)
It provides efficient use of underlying hardware.
(iv)
It can utilize the resources available remotely. Q.22 What is PCB? What is its role?
Ans: While creating a process the
operating system performs several operations. To identify these process, it
must identify each process, hence it assigns a process identification number
(PID) to each process. As the operating system supports multi-programming, it
needs to keep track of all the processes. For this task, the process control
block (PCB) is used to track the process‘s execution status. Each block of
memory contains information about the process state, program counter, stack
pointer, status of opened files, scheduling algorithms, etc. All these
information is required and must be saved when the process is switched from one
state to another. When the process made transitions from one state to another,
the operating system must update information in the process‘s PCB.
A
process control block (PCB) contains information about the process, i.e.
registers, quantum,
priority, etc.
Pointer – It is a stack pointer which
is required to be saved when the process is switched from
one state to another to retain
the current position of the process.
Process state – It stores the respective state of the process.
Process
number – Every process is assigned with a unique id known as process ID or
PID which stores the process identifier.
Program
counter – It stores the counter which contains the address of the next
instruction that is to be executed for the process.
Register
– These are the CPU registers which includes: accumulator, base, registers
and general purpose registers.
Memory
limits – This field contains the information about memory management system
used by operating system. This may include the page tables, segment tables etc.
Open files list –
This information includes the list of files opened for a process.
0 comments:
Post a Comment
Thanks for leaving a comment. As soon as it's approved, it will appear.