Q1)Illustrate the differences between machine language, assembly
language and high-level languages for so ware developement?
Machine Assembly
Point High-Level Language
Language Language
Lowest-level Low-level High-level, human-
1. Level
(binary) symbolic friendly
Mnemonics English-like words (if,
2. Representa on 0s and 1s
(MOV, ADD) for)
Moderately
3. Readability Very difficult Highly readable
readable
4. Hardware Fully hardware Hardware
Hardware independent
Dependence dependent dependent
5. Portability Not portable Not portable Highly portable
Easier than Easy with
6. Error Detec on Very hard
machine compiler/interpreter
Slower due to
7. Execu on Speed Fastest Fast
transla on
8. Translator
None Assembler Compiler/Interpreter
Required
9. Development
Longest Moderate Shortest
Time
Drivers,
Firmware, Applica on, web,
10. Usage embedded
system-level so ware
systems
Q1)Define system so ware and its component?
1. System so ware is a set of programs that manages and controls computer
hardware.
2. It acts as an interface between hardware and applica on so ware.
3. Opera ng System (OS) is a key component that handles process, memory, and
file management.
4. Device drivers enable communica on between the OS and hardware devices.
5. U lity programs perform system maintenance tasks like an virus, backup, and
disk cleanup.
6. Language translators (compiler, assembler, interpreter) convert programs into
machine code.
7. Firmware is permanent so ware stored in ROM to control hardware func ons.
8. Boot loader ini alizes hardware and loads the opera ng system at startup.
9. System security so ware protects the system from unauthorized access and
threats.
[Link] so ware manages data communica on, protocols, and connec vity
in a network.
Q2)Explain macro instruc ons and how they are defined?
A macro instruc on is a single statement that expands into a group of assembly
instruc ons.
Macros are used to reduce repe ve coding in assembly language programs.
A macro is defined using the MACRO direc ve and ends with the MEND direc ve.
The sequence of instruc ons inside a macro is called the macro body.
Macros can accept parameters, allowing flexible and reusable code genera on.
When a macro is invoked, the assembler replaces the macro call with its
expanded instruc ons.
This process is called macro expansion and happens before actual assembly
transla on.
Macros help improve program readability and reduce the chance of manual
errors.
They increase speed of development because programmers write fewer
repe ve lines.
Macros do not generate separate object code—they simply expand inline
wherever called.
Q2)Design of a Single Pass and Two Pass Assembler Macro language
and macro processor?
A single-pass assembler scans the program once and generates machine code
immediately.
It uses backpatching to handle forward references.
A two-pass assembler scans the program twice for easier symbol resolu on.
Pass-1 of a two-pass assembler builds the symbol table and assigns addresses.
Pass-2 uses the symbol table to generate final machine code.
A macro language allows defining a group of instruc ons using MACRO and
MEND.
Macros reduce repe on by expanding a single macro call into mul ple
instruc ons.
A macro processor performs macro expansion before assembly.
It uses tables like MNT (Macro Name Table) and MDT (Macro Defini on Table).
The macro processor subs tutes parameters and inserts expanded code into the
source program.
Q3)What are the subrou ne linkages? How do they facilitate program
modularity?
Subrou ne linkage is the mechanism used to call and return from subrou nes.
It stores the return address so control can come back to the main program.
It provides methods for passing parameters to subrou nes.
It allocates space for local variables during subrou ne execu on.
It preserves registers and machine state before entering the subrou ne.
It uses a return instruc on to transfer control back to the caller.
Subrou ne linkage enables dividing programs into independent func onal
modules.
It improves code reusability, as the same subrou ne can be called many mes.
It increases readability and maintainability through structured program design.
It supports modular programming, allowing each subrou ne to be developed,
tested, and debugged separately.
Q3)Describe the characteris cs and func ons of each loader schemes?
Absolute Loader loads the program directly into a fixed memory loca on.
Absolute Loader performs no reloca on or linking, making it simple but inflexible.
Reloca ng Loader modifies address-dependent instruc ons using reloca on bits.
Reloca ng Loader allows programs to run at any available memory loca on.
Linking Loader resolves external symbol references across mul ple program
modules.
Linking Loader combines modules and performs reloca on before execu on.
Dynamic Loader loads rou nes only when they are required during execu on.
Dynamic Loader reduces memory usage by avoiding loading unused modules.
Loader schemes support modular programming by managing mul ple object
modules.
All loaders ensure program execu on by alloca ng memory, resolving addresses,
and ini a ng program start.
Q4)What is compiler? Exlain any two phases of compiler with suitable
diagram. Explain the concept of LEX and YACC with suitable examples?
A compiler is a language translator that converts high-level source code into
machine code through mul ple systema c phases.
Lexical Analysis Phase breaks the program into tokens (keywords, iden fiers,
operators) and removes comments/whitespace.
Lexical Analysis Diagram:
Source Code → [Lexical Analyzer] → Tokens → Symbol Table
Syntax Analysis Phase checks gramma cal structure using context-free grammar
and produces a parse tree.
Syntax Analysis Diagram:
Tokens → [Syntax Analyzer] → Parse Tree
LEX is a lexical analyzer generator that automa cally creates tokenizers based on
user-defined pa erns.
LEX Example:
DIGIT [0-9]
{DIGIT}+ { prin ("NUMBER"); }
YACC (Yet Another Compiler Compiler) generates parsers that check syntax using
grammar rules.
YACC Example: expr : expr '+' expr | NUMBER ;
LEX and YACC work together where LEX handles tokens and YACC handles
grammar, forming a complete front-end for compilers.
Q4) What are the advantages and disadvantages of top-down parsing
techniques with examples compare using tabular format.
Aspect Advantages Disadvantages Example
Not good for
Simplicity Easy to implement LL(1)
complex grammars
Parsing Top-down from start Recursive-
Backtracking issues
Direc on symbol descent
Works for non-le - Fails with le
Grammar Need Clean grammar
recursive grammars recursion
Look-Ahead Reduces backtracking Must be LL(1) FIRST/FOLLOW
Fast for simple Slow with
Efficiency Parse table
grammars backtracking
Poor deep-error Early syntax
Error Handling Early error detec on
handling error
Hard with many Simple
Parse Tree Easy to build
choices expressions
Needs grammar
Implementa on Straigh orward LL(1) conversion
rewri ng
Q5)Describe the lifecycle of process and the various states?
A process is a program in execu on, and its lifecycle is managed by the opera ng
system.
1. New State – The process is created and PCB (Process Control Block) is ini alized.
2. Ready State – The process is loaded in main memory and wai ng for CPU
alloca on.
3. Running State – The process is currently being executed by the CPU.
4. Wai ng/Blocked State – The process cannot con nue un l an event occurs (I/O
comple on, resource availability).
5. Ready Suspended State – The process is moved to secondary memory; ready but
not in main RAM.
6. Blocked Suspended State – The process is both blocked and swapped out to
secondary storage.
7. Terminated/Exit State – The process completes execu on or is killed by the OS.
8. The state transi ons occur due to scheduling, I/O requests, interrupts, or
comple on of tasks.
9. The OS uses the Process Control Block (PCB) to track process state, resources,
registers, and scheduling informa on throughout the lifecycle.
Q5)How do os manage memory? Discuss concept such as paging,
segmenta on and memory alloca on stratergies.
The Opera ng System manages memory to ensure efficient use of RAM, prevent
conflicts, and allocate space to processes safely.
OS uses Memory Management Unit (MMU) to translate logical addresses into
physical addresses.
Paging divides memory into fixed-size blocks: frames (physical) and pages
(logical), elimina ng external fragmenta on.
In paging, a page table maps each logical page to its physical frame.
Segmenta on divides memory based on logical program units like code, data,
stack, suppor ng variable-size segments.
Segmenta on uses a segment table containing base and limit for each segment,
enabling protec on and sharing.
Paging + segmenta on can be combined for efficient and protected memory
access.
Con guous alloca on assigns a single con nuous block to a process; simple but
suffers from fragmenta on.
Non-con guous alloca on (paging/segmenta on) allows processes to be spread
across memory, improving u liza on.
OS uses alloca on strategies like First Fit, Best Fit, Worst Fit to assign memory
blocks dynamically during process execu on.
Q6)Illustrate basic opera on of a device driver using line printer as an
example. Explain how the driver manages data transfer and interrupts.
A. Basic Opera on of a Line Printer Driver (5 Points — Trimmed)
1. Ini aliza on: Detects printer, allocates buffers, maps I/O ports, resets device.
2. Command Issuing: Sends print-related commands to hardware registers.
3. Buffer Management: Stores output in a buffer and sends characters
sequen ally.
4. Status Monitoring: Checks printer status (busy, ready, paper-out).
5. Error Handling: Reports issues (jam, offline) and waits for correc on.
B. Driver Data Transfer Methods (3 Points — Trimmed)
6. Programmed I/O: Driver writes a character and waits un l printer is ready.
7. Buffered Transfer: Uses buffers to reduce CPU wai ng and improve speed.
8. DMA : Transfers large data blocks directly to printer with minimal CPU use.
C. Interrupt Management (2 Points — Trimmed)
9. Interrupt Handling: Printer triggers an interrupt when ready; ISR sends next
character.
10.Efficient CPU Use: Interrupts eliminate busy wai ng, freeing CPU for other tasks.
Q6)Compare and contrast device driver implementa on in Unix and
Windows opera ng systems. Highlight key architectural and func onal
differences.
Architecture: Linux – monolithic, kernel modules; Windows – hybrid, WDM/WDF.
1. Driver Types: Linux – char, block, network (/dev); Windows – kernel, user,
miniport, filter.
2. Loading: Linux – insmod/modprobe; Windows – PnP Manager, .sys files.
3. Hardware Access: Linux – open(), read(), write(), ioctl(); Windows – IRPs.
4. Kernel Interfaces: Linux – VFS, networking, TTY, block; Windows – layered I/O
(I/O Manager, HAL, KMDF/UMDF).
5. Security: Linux – /dev permissions; Windows – ACLs and driver signing.
6. User-Level Drivers: Linux – rare (FUSE); Windows – supported via UMDF.
7. Development Tools: Linux – GCC, Makefiles, dmesg; Windows – Visual Studio,
WDK, WinDbg.
8. Stability: Linux – kernel crash if driver fails; Windows – user-mode improves
isola on.
9. Portability: Linux – highly portable; Windows – less portable, strict specs.
Q3)Describe dynamic binders and dynamic link libraries (DLLs). Explain
their role in modern opera ng systems and program modularity.
Dynamic binders perform linking of program modules at run me, not during
compila on or loading.
They resolve external references only when a func on or module is actually
needed.
Dynamic binders reduce program load me because only essen al modules are
linked ini ally.
They allow upda ng or replacing individual modules without recompiling the
en re program.
DLLs (Dynamic Link Libraries) are shared libraries loaded into memory only when
required.
Mul ple programs can share the same DLL, reducing total memory usage and
saving disk space.
DLLs support code reuse, as common rou nes are stored separately and used
across applica ons.
In modern opera ng systems, DLLs enable modular design by keeping program
components independent.
Dynamic linking improves performance by loading only the needed rou nes,
improving RAM efficiency.
Together, dynamic binders and DLLs enhance program modularity,
maintainability, and flexibility in modern OS environments.
Q4)What are the basic func ons of compiler? describe its main phases
in detail.
A compiler translates high-level source code into machine or intermediate code.
It performs lexical analysis by breaking code into tokens and building the symbol
table.
It performs syntax analysis to check grammar and generate a parse tree.
It performs seman c analysis to ensure correct meaning, type checking, and
scope valida on.
It generates intermediate code that is machine-independent and easy to
op mize.
The compiler op mizes code by removing redundancies and improving
performance.
It generates target machine code with proper register and memory alloca on.
A compiler manages symbol tables to store iden fiers, types, and addresses.
It performs error detec on and repor ng during lexical, syntax, and seman c
stages.
It ensures efficient execu on by producing op mized and correct machine-level
output.
Q2)What is forward referance and how does single-pass assembler
handle them? Adi onally, provide a comprehensive explana on of the
component of system so ware?
A forward reference occurs when a label is used before it is defined later in the
program.
Single-pass assemblers cannot know the address of such labels during the first
encounter.
To handle this, they use a forward reference table (or unresolved reference list).
They perform backpatching, meaning the assembler fills in the correct address
later when the label is finally defined.
This allows single-pass assemblers to con nue processing without scanning the
en re program again.
Opera ng System (OS): Manages hardware, memory, processes, and file system.
Device Drivers: Enable communica on between OS and hardware devices
(keyboard, printer, etc.).
U lity Programs: Perform system maintenance tasks like an virus, backup, file
compression.
Language Translators: Compilers, assemblers, and interpreters convert programs
into machine code.
Firmware & Boot Loader: Provide low-level hardware control and load the OS
during startup.
Q2)Explain the features of a macro facility. How do macro processors
improve programming efficiency and code reusability?
A macro facility allows defining a group of instruc ons under a single name.
Macros are defined using MACRO and MEND direc ves.
Macros support parameters, enabling customizable instruc on sequences.
They allow default values for parameters.
Macros permit nested macros, enabling structured code expansion.
Macro processors expand macro calls before assembly, replacing them with full
instruc on sequences.
They eliminate repe ve coding by allowing reuse of commonly used instruc on
blocks.
Macro processors improve programming speed because one macro call expands
into mul ple lines of code.
They reduce errors by avoiding repeated manual wri ng of iden cal instruc on
pa erns.
Macros enhance code readability and maintainability, improving overall
programming efficiency and reusability.
Q1)How do language translator facilitate the process of programming in
high-level languages?
They convert high-level language code into machine language understood by the
computer.
Translators allow programmers to write code using English-like syntax, improving
readability.
They detect and report errors, helping debug programs efficiently.
Translators op mize code for be er performance during execu on.
They ensure portability by allowing the same high-level code to run on different
systems.
Translators manage memory and resource alloca on during code genera on.
They support modular programming through linking and loading of mul ple
program files.
Translators enforce syntax rules, ensuring that programs follow proper structure.
They translate complex instruc ons into mul ple machine-level commands
automa cally.
Translators increase programming produc vity by reducing coding effort and
development me.
Q1)Explain the evolu on of system so ware. How have opera ng
systems, assemblers, and compilers developed over me to support
modern compu ng?
They convert high-level language code into machine language understood by the
computer.
Translators allow programmers to write code using English-like syntax, improving
readability.
They detect and report errors, helping debug programs efficiently.
Translators op mize code for be er performance during execu on.
They ensure portability by allowing the same high-level code to run on different
systems.
Translators manage memory and resource alloca on during code genera on.
They support modular programming through linking and loading of mul ple
program files.
Translators enforce syntax rules, ensuring that programs follow proper structure.
They translate complex instruc ons into mul ple machine-level commands
automa cally.
Translators increase programming produc vity by reducing coding effort and
development me.
Q6) Define device drivers and explain their anatomy and what is their
primary purpose in opera ng system?
A device driver is system so ware that acts as an interface between the OS and
hardware, transla ng OS commands into device-specific opera ons.
Key Components
1. Ini aliza on rou nes – setup device during boot/connec on.
2. Interrupt handlers – manage hardware interrupts.
3. IOCTL interface – control commands to the device.
4. Read/Write rou nes – transfer data to/from hardware.
5. Buffers – temporary data storage.
6. Configura on code – device se ngs (speed, mode, DMA).
7. Error handling – detect and recover from faults.
8. Device registra on – register driver with OS kernel.
Purpose of a Device Driver
1. Translates OS commands into hardware opera ons.
2. Provides hardware independence for applica ons.
3. Ensures secure, controlled access to devices.
4. Manages data transfer, interrupts, buffering, ming.
5. Offers standard interfaces (e.g., Linux /dev/).
Q6)Analyze the role of device drivers in web-based technologies and explain how
they enable hardware-so ware interac on trough browser or cloud interfaces.
Hardware Abstrac on – Drivers act as the layer between OS and hardware,
enabling indirect access for web apps (camera, mic, GPU).
Browser Hardware Access – Web APIs (WebUSB, WebRTC, WebGPU,
WebBluetooth) use OS drivers internally.
Security & Permissions – Drivers help browsers enforce permissions and validate
devices.
Cloud-Controlled Devices – Cloud services use local agents that depend on
drivers (cloud prin ng, IoT).
Kernel Services for Browsers – Browsers rely on GPU, audio, and network drivers
for accelera on and playback.
Real-Time Media (WebRTC) – Uses camera/mic drivers for streaming.
Peripheral Communica on – WebUSB/WebBluetooth communicate with sensors
and controllers via OS drivers.
Cloud IoT Access – Cloud agents read device data through drivers and send it to
the cloud.
GPU Rendering/ML – WebGPU/WebGL depend on graphics drivers for rendering
and in-browser ML.
Virtual Devices – Virtual drivers support virtual cameras, adapters, and emulated
hardware.
Q5)Explain the advantages and disadvantages of system call.
1. Provides controlled access to hardware ensuring safe interac on with devices
like disk, network, and memory.
2. Enhances security by preven ng user programs from execu ng privileged
instruc ons directly.
3. Ensures stability because system calls run in kernel mode with proper checks
and valida ons.
4. Improves portability as the same system call interface works across different
hardware pla orms.
5. Simplifies programming by offering ready-made OS services such as file
handling, process control, and communica on.
Disadvantages (5 Points)
6. Slower than normal func on calls because system calls require switching from
user mode to kernel mode.
7. Higher overhead due to context switching and privilege checks performed by the
OS.
8. Limited flexibility since system calls follow strict OS-defined formats and rules.
9. Debugging complexity increases because errors inside kernel-level opera ons
are harder to trace.
[Link] risks may arise if system calls are misused or exploited (e.g., buffer
overflow, privilege escala on).
Q5)Explain the process control in context of opera ng system.
1. Process control refers to the OS's ability to create, manage, schedule, and
terminate processes effec vely.
2. The OS uses a Process Control Block (PCB) to store essen al process informa on
like state, registers, memory limits, and scheduling data.
3. Process crea on is done using system calls such as fork(), exec(), or
CreateProcess(), allowing new processes to start execu on.
4. Process termina on removes a process from the system using calls like exit() or
kill(), releasing all allocated resources.
5. Process scheduling is a major part of process control where the OS decides
which process gets CPU me using algorithms like FCFS, Round Robin, or Priority
Scheduling.
6. State transi on management is handled by the OS as processes move between
new, ready, running, wai ng, and terminated states.
7. Context switching is performed by the OS to save the state of the running
process and load the state of the next ready process.
8. Inter-process communica on (IPC) is managed to allow processes to exchange
data through pipes, shared memory, message queues, etc.
9. Synchroniza on control prevents race condi ons using mechanisms like
semaphores, monitors, and mutex locks.
10. Process protec on and security ensure that processes do not interfere with
each other’s memory or resources, maintaining system stability.
Q4)List and explain the phases of compila on with suitable example?
Phases of Compila on (with Example)
Example (Input: x = a + b
Phase Func on
* 5)
Converts characters → tokens; ID(x), =, ID(a), +, ID(b), *,
1. Lexical Analysis
removes spaces/comments NUM(5)
2. Syntax Analysis Checks grammar; builds parse tree x = a + (b * 5)
3. Seman c Ensures a, b, x declared &
Type checking, declara on checking
Analysis compa ble
4. Intermediate
Produces IR (TAC, pos ix) t1=b*5; t2=a+t1; x=t2
Code Gen
Constant folding, dead
5. Op miza on Improves code efficiency
code removal
6. Code MOV R1,b; MUL R1,5;
Converts IR → machine code
Genera on ADD R1,a; MOV x,R1
7. Symbol Table & Tracks iden fiers, types; handles Records x, a, b, 5 with
Errors errors type/scope
1. Lexical Analysis
• Characters → tokens
• Removes whitespace/comments
• Uses regex & finite automata
2. Syntax Analysis
• Checks structure
• Uses LL/LR parsing
• Builds parse tree
3. Seman c Analysis
• Type/seman c checks
• Ensures correct declara ons
• Annotated syntax tree
4. Intermediate Code Genera on
• High-level → IR (TAC, pos ix)
• Machine independent
5. Op miza on
• Faster & smaller code
• Constant folding, loop & dead-code op miza on
6. Code Genera on
• IR → machine code
• Register alloca on
7. Symbol Table & Error Handling
• Stores iden fiers, scope, types
• Reports lexical, syntax, seman c errors
Q1)Describe the basic structure of a machine. Explain how
understanding machine architecture is important for system so ware
development.
Input Unit – Accepts data and instruc ons from external devices.
Output Unit – Sends processed results to display or storage devices.
Memory Unit (Primary Storage) – Stores data and instruc ons temporarily
(RAM) and permanently (ROM).
Arithme c Logic Unit (ALU) – Performs all arithme c and logical opera ons.
Control Unit (CU) – Directs the execu on of instruc ons and controls system
opera ons.
Central Processing Unit (CPU) – Combina on of ALU + CU; acts as the “brain’’ of
the computer.
Registers – High-speed storage loca ons inside CPU for immediate data and
instruc on handling.
System Bus – Collec on of data, address, and control buses connec ng
components.
Secondary Storage – Long-term data storage (HDD, SSD).
I/O Interfaces – Manage communica on between CPU/memory and external
devices.
Q1)Discuss the basic process of language transla on. How does source
code in a high-level language get converted into machine-executable
code?
Programmer writes source code in a high-level language.
Compiler/interpreter reads the source code.
Lexical analysis converts code into tokens.
Syntax analysis checks grammar and structure.
Seman c analysis verifies meaning and type correctness.
Intermediate code is generated.
Code op miza on improves efficiency.
Machine code is generated from op mized IR.
Linker combines machine code with libraries to form an executable.
Loader loads the executable into memory for CPU execu on.
Q2)What are key features of macro facility in microprocessor? explain
in detail.
A macro groups mul ple assembly instruc ons under a single name.
Macros are defined using MACRO and terminated using MEND.
They support parameters, allowing flexible code genera on.
Posi onal parameters and keyword parameters can be used.
Default values can be provided for macro parameters.
Macros increase code reusability by allowing repeated use of common
instruc on blocks.
A macro call is replaced by its full instruc on sequence (macro expansion).
Macro expansion happens before actual assembly (during preprocessing).
Macros can be nested, i.e., a macro can call another macro.
They reduce coding errors and improve readability by avoiding repe ve manual
coding.
Q3) What are the main func ons of a loader? Describe the loader
scheme in detail.
Loading: Transfers the object program from secondary storage to main
memory.
Alloca on: Assigns memory loca ons for program segments, data, and stack.
Reloca on: Adjusts address-dependent instruc ons so the program can run at
any memory loca on.
Linking: Resolves external references between different program modules.
Execu on Ini a on: Passes control to the program’s star ng address a er loading is
complete.
Input Handling: Loader reads the object program and its associated informa on
(header, text, reloca on, and external symbol tables).
Program Alloca on: Loader determines required memory and assigns suitable
memory blocks for code, data, and stack.
Symbol Resolu on (Linking): All external symbols are matched and resolved
using the symbol table.
Reloca on Processing: Reloca on bits guide the loader to modify address-
dependent instruc ons using the reloca on factor.
Loading of Program: The text (instruc ons + data) sec ons are placed into their
designated memory loca ons.
Q3)What are the main func ons of loader? describe the loader scheme
in detail.
Loading: The loader transfers the object program from secondary storage into
main memory.
Alloca on: It assigns appropriate memory loca ons for code, data, and stack
segments.
Reloca on: It adjusts address-dependent instruc ons using reloca on
informa on so the program can run at any memory loca on.
Linking: It resolves external symbol references between different program
modules.
Mapping: It converts logical addresses in the object program to actual physical
memory addresses.
Text Loading: It places machine instruc ons and data into their final assigned
memory loca ons.
Se ng Program Start Address: It ini alizes the Program Counter (PC) with the
entry point of the program.
Execu on Ini a on: The loader transfers control from the opera ng system to
the loaded program for execu on.
Error Checking: It verifies the correctness of object modules (headers, reloca on
bits, symbol references).
General Loader Scheme: The loader reads the object file → allocates memory →
performs linking and reloca on → loads text/data → sets start address → hands
over control for execu on.
Q3)Explain General loader scheme with advantages and disadvantages?
Loader reads the object program and its control informa on (header, text,
reloca on, symbol tables).
Performs memory alloca on for code, data, and stack segments.
Carries out linking by resolving external symbol references across modules.
Performs reloca on by adjus ng address-dependent instruc ons using reloca on
bits.
Loads the text (machine code) and data into their assigned memory loca ons.
Sets the program entry point and transfers control to begin execu on.
Supports mul -module programs through linking and reloca on.
Allows programs to be loaded at any memory loca on, improving memory
flexibility.
More complex than simple loaders due to linking and reloca on steps.
Takes extra me during loading because of symbol resolu on and reloca on
processing.
Q4)What is the significance of error handling during compila on
discuss startergies for detec ng and recovering from errors.
Error handling ensures the compiler detects mistakes early and improves
program correctness.
It prevents the genera on of wrong machine code by stopping compila on on
serious errors.
Good error messages help programmers debug programs faster and more
accurately.
The compiler can con nue a er minor errors to report mul ple issues in a single
run.
Errors are detected at three levels: lexical, syntax, and seman c analysis.
In lexical errors, invalid characters or malformed tokens are iden fied and
reported.
In syntax errors, missing symbols or incorrect grammar structures are caught by
the parser.
Panic-mode recovery skips input un l a safe token is found, allowing parsing to
resume.
Phrase-level recovery makes small correc ons like inser ng or dele ng tokens
automa cally.
Error produc ons and global correc on help the compiler handle common
pa erns of mistakes and a empt minimal modifica ons.
Q4)Explain bo om-up parsing techniques. Discuss operator-precedence
parsing and its advantages in syntax analysis.
Bo om-up parsing builds the parse tree from leaf (tokens) to root (start symbol)
by repeatedly reducing substrings to grammar symbols.
It works by finding the rightmost deriva on in reverse, making it suitable for
many programming language grammars.
The two main opera ons used are shi (read next token) and reduce (replace
handle with a non-terminal).
It detects a handle, which is the substring matching the RHS of a produc on, and
reduces it during parsing.
Shi –reduce parsing is the most common bo om-up method and forms the basis
of LR parsers.
Operator-precedence parsing is a special type of bo om-up parsing based on
defining precedence rela ons between operators.
It uses an operator-precedence table to determine whether to shi or reduce
based on rela ons like <., =., >..
Operator-precedence grammars avoid ambiguity for arithme c expressions using
rules for operator priority and associa vity.
Advantages: simple implementa on, efficient handling of expressions, and
minimal need for backtracking.
It improves syntax analysis by resolving conflicts between operators
automa cally, making expression parsing fast and reliable.
Q5)What is Opera ng system? Explain various services offered by OS.
Explain different types of OS?
A. Defini on of Opera ng System
1. OS is system so ware ac ng as an interface between user and hardware.
2. It manages resources (CPU, memory, I/O) and provides a secure, efficient
environment for applica ons.
B. Services of an Opera ng System
3. Process Management – Creates, schedules, ends processes.
4. Memory Management – Allocates/deallocates RAM (paging, segmenta on).
5. File Management – Manages file opera ons and directory structure.
6. I/O Management – Controls devices via drivers.
7. Security – Authen ca on, access control.
8. Error Handling – Detects and recovers from errors.
9. Networking – Supports system/process communica on.
C. Types of Opera ng Systems
[Link] OS – Runs jobs in batches.
[Link]-Sharing OS – Mul ple users/programs share CPU.
[Link]-Time OS – Fast response for cri cal tasks.
[Link] OS – Manages networked machines as one system.
[Link] processing OS – Uses mul ple CPUs.
[Link] OS – For small devices (robots, appliances, sensors).
Q5)Explain various process states with suitable process state diagram. What is
system call in OS also explain various system calls in OS?
• New – Process created; PCB ini alized.
• Ready – In memory, wai ng for CPU.
• Running – Currently execu ng.
• Blocked/Wai ng – Wai ng for I/O or event.
• Terminated – Execu on finished; PCB removed.
• Ready Suspended – Ready but swapped to secondary memory.
• Blocked Suspended – Blocked and swapped out.
System Call (Short Defini on)
A system call is a request by a user program to the OS for services requiring kernel
privileges (e.g., file, process, memory, I/O opera ons).
Types of System Calls (Trimmed)
• Process Control – create/terminate processes (fork, exec, exit).
• File Management – open/read/write/close files.
• Device Management – request/release devices (ioctl).
• Informa on – get system/process info (getpid, me).
• Communica on – IPC using pipes, shared memory, sockets.
Q6)What are some common challenge faced in device driver
development?
Hardware Complexity – Drivers must handle low-level hardware details,
registers, interrupts, and ming, which increases development difficulty.
Lack of Hardware Documenta on – Many devices provide incomplete or
proprietary specifica ons, making driver development harder.
Kernel-Level Programming – Drivers run in kernel mode, where mistakes can
crash the en re system (not just the applica on).
Concurrency and Synchroniza on Issues – Drivers must handle interrupts,
mul ple threads, and shared resources without causing deadlocks or race
condi ons.
Portability Limita ons – Drivers o en depend on OS-specific APIs, making it
difficult to port them across pla orms like Windows, Linux, or macOS.
Tes ng Difficul es – Hardware-dependent tes ng is slow, costly, and requires
real devices; bugs are hard to reproduce.
Performance Op miza on – Drivers must manage hardware efficiently to reduce
latency and improve throughput, which requires deep tuning.
Security Requirements – Drivers must ensure safe access to hardware and
protect against malicious a acks or unauthorized device control.
Compa bility Issues – Drivers must work with different versions of OS kernels,
hardware revisions, and firmware updates.
Error Handling and Recovery – Drivers must safely handle hardware failures,
invalid inputs, and unexpected states without causing system instability.
Q6) Explain device programming? How do device driver facilitate
communica on between the opera ng system and hardware?
A. Device Programming
1. Wri ng low-level code to control hardware (printers, disks, keyboards, sensors)
2. Involves handling hardware registers, interrupts, DMA, and communica on
protocols.
3. Requires understanding of hardware specs, memory maps, and ming
constraints.
4. Uses I/O instruc ons, configura on commands, and status checking.
5. Typically implemented inside device drivers for ini aliza on, data transfer, and
error handling.
B. How Device Drivers Enable OS–Hardware Communica on:
6. Interface Layer: Drivers translate OS commands into hardware-specific ac ons.
7. Hardware Abstrac on: Provide a uniform API, hiding device complexity from
OS/apps.
8. Interrupt Handling: Process hardware interrupts and no fy the OS of important
events.
9. Data Transfer: Manage Programmed I/O, Interrupt-Driven I/O, and DMA for
efficient data flow.
[Link] aliza on & Configura on: Set hardware registers, load firmware, and
prepare the device for use.
Q3)Explain the concept of binders in program execu on. How do
linking loaders differ from tradi onal binders, and what are their
advantages?
A binder combines mul ple object modules into a single complete executable
program.
It resolves external symbol references during compile me (before loading).
A binder produces a fully linked executable stored permanently on disk.
It performs linking only once, so the executable can be reused without re-linking.
A linking loader performs linking during load me, not at compile me.
Linking loaders link and relocate modules directly in main memory.
Linking loaders allow programs to be loaded at any memory address, improving
flexibility.
Linking loaders reduce disk space because fully linked executables are not stored.
They support dynamic linking, loading rou nes only when required at run me.
Linking loaders improve modularity and memory efficiency compared to
tradi onal binders.
Q3)Discuss overlays and their use in memory management. How do
overlays help execute large programs on limited memory systems?
Overlays are a memory management technique used to run large programs in
limited main memory.
A program is divided into smaller, independent blocks called overlay segments.
Only the required overlay segment is loaded into memory at a me.
Overlay segments that are not needed are kept on secondary storage (disk).
When a new segment is needed, it replaces the currently loaded segment
without affec ng the rest of the program.
Overlays allow programs whose total size exceeds physical memory to execute
successfully.
The programmer or compiler defines the overlay structure and specifies which
modules can coexist.
It reduces memory usage by ensuring only ac ve modules occupy RAM.
Overlays support modular programming by separa ng code into logical,
independently used sec ons.
Overlays improve system efficiency in older or embedded systems where
memory is very limited.
Q2)Explain the macro and design of macroprocessor.
A macro is a single instruc on that expands into a sequence of assembly
language instruc ons.
It is defined using MACRO (start) and MEND (end) direc ves.
Macros may include parameters to allow flexible and reusable code.
When a macro is called, the assembler replaces the call with its full expanded
instruc on set (macro expansion).
Macros reduce repe ve coding, improve readability, and simplify assembly-level
programming.
A macro processor expands macros before the actual assembly begins
(preprocessing stage).
It uses a Macro Name Table (MNT) to store macro names and informa on.
A Macro Defini on Table (MDT) stores the actual macro body (instruc ons).
An Argument List Array (ALA) holds parameters and subs tutes them during
expansion.
The macro processor scans source code, iden fies macro calls, retrieves
defini ons from MNT/MDT, subs tutes parameters via ALA, and inserts expanded
code into the code stream.
Q2)What is structure of an assembler? Describe its components and
func ons.
Input Buffer: Reads the assembly source program line by line for processing.
Lexical Analyzer: Breaks each line into tokens such as mnemonics, labels, and
operands.
Symbol Table (SYMTAB): Stores label names along with their assigned memory
addresses.
Opcode Table (OPTAB): Contains machine opcodes and instruc on formats for all
mnemonics.
Loca on Counter (LC): Tracks the current memory address for each instruc on
during transla on.
Intermediate Representa on (IR): Stores par ally processed instruc ons for later
assembly steps.
Pass Logic Unit: Performs address assignment, instruc on verifica on, and
assembly transla on.
Error Handler: Detects syntax errors, undefined symbols, wrong operand types,
etc.
Object Code Generator: Produces final machine code or object code using
SYMTAB and OPTAB.
Output Module: Writes the generated object code, lis ng file, or executable
output for lo
Q1)Compare and contrast assemblers, compilers, and interpreters in
terms of their working principles, advantages, and typical use cases?
Point Assembler Compiler Interpreter
Converts assembly Converts high-level code
1. Working Executes high-level
code to machine to machine
Principle code line by line
code code/executable
Translates and
2. Transla on One-to-one Translates en re program
executes each line
Method instruc on mapping at once
immediately
3. Execu on Slowest due to
Fastest Fast a er compila on
Speed repeated transla on
4. Error Reports low-level Reports all errors before Reports errors during
Handling syntax errors execu on execu on
No separate
5. Output Machine code file Standalone executable
executable
Not portable
Partly portable (depends Highly portable across
6. Portability (hardware-
on compiler) systems
dependent)
Embedded systems, System so ware, large Scrip ng, tes ng,
7. Use Cases
drivers applica ons rapid development
Requires manual Automa c op miza on Minimal or no
8. Op miza on
op miza on performed op miza on
9. Memory
Low High Moderate
Requirement
10. Examples MASM, NASM GCC, Clang, javac Python, Ruby, PHP
Q2)Describe the structure of assembler. How does a single-pass
assembler differ from a two-pass assembler?
An assembler reads assembly language and converts it into machine code.
It contains an input buffer to read source instruc ons.
A lexical analyzer separates mnemonics, labels, and operands.
A symbol table is maintained to store label names and their addresses.
An opcode table (OPTAB) stores machine opcodes for each mnemonic.
An address counter keeps track of instruc on memory loca ons.
A single-pass assembler scans the source program only once.
Single-pass assemblers struggle with forward references (labels used before
being defined).
A two-pass assembler scans the source program twice—first to build the symbol
table, second to generate code.
Two-pass assemblers handle forward references easily and generate more
accurate machine code.
Q6)Describe the different types of device drivers. Explain the difference between
kernel-level and user-level drivers with suitable examples.
A. Types of Device Drivers
1. Character Drivers: Handle byte-stream devices (keyboard, mouse, serial ports).
2. Block Drivers: Manage block-storage devices like HDDs, SSDs, USB drives.
3. Network Drivers: Control NICs for sending/receiving network data.
4. USB Drivers: Communicate with USB devices (cameras, printers, storage).
5. Virtual Drivers: Provide so ware-emulated devices (virtual NIC, virtual audio).
6. Plug-and-Play Drivers: Auto-detect, configure, and install hardware.
7. File System Drivers: Support file systems (NTFS, FAT32, ext4).
8. Graphics Drivers: Control GPU hardware for rendering and accelera on.
B. Kernel-Level vs User-Level Drivers
Kernel-Level Drivers:
9. Run in kernel mode with full hardware access; fast but risky if buggy.
10. Used for cri cal devices (disk, GPU, NIC).
11. Example: Linux kernel modules, Windows .sys drivers.
User-Level Drivers:
12. Run in user space with restricted access; safer but slightly slower.
13. Used for non-cri cal devices (printers, cameras, USB gadgets).
14. Example: Windows UMDF drivers, Android HAL drivers.
Q6)Explain the installa on and incorpora on of driver rou nes in an
opera ng system. Discuss the key steps involved in ini alizing and
configuring a new device driver.
A. Installa on & Incorpora on of Driver Rou nes in an OS
1. Driver Detec on – The OS detects new hardware through Plug-and-Play (PnP) or
manual installa on.
2. Driver Loading – The OS loads the driver file into memory (.sys in Windows).
3. Driver Registra on – The driver registers itself with OS subsystems (I/O
manager, PCI manager, USB stack, etc.) and announces supported devices.
4. Crea on of Device Files/Interfaces – The OS creates device nodes or symbolic
interfaces so applica ons can access the hardware.
5. Interrupt & Resource Assignment – OS assigns IRQ lines, memory-mapped I/O
regions, DMA channels, and port addresses required for the device to operate.
B. Steps for Ini alizing & Configuring a New Device Driver
6. Hardware Iden fica on – The driver reads device IDs, vendor IDs, and
configura on space to ensure the correct hardware is present.
7. Resource Alloca on – The driver maps hardware registers into memory,
allocates buffers, sets up DMA, and reserves system resources.
8. Interrupt Handler Setup – The driver registers an interrupt service rou ne (ISR)
to handle hardware-generated events.
9. Device Ini aliza on – The driver sends ini aliza on commands, resets the
device if necessary, and loads firmware (if required).
[Link] ng & Status Verifica on – The driver verifies that hardware responds
correctly, updates device status, and makes it ready for applica ons to use.
Q5)Compare and contrast different types of shells (Bourne Shell, Bash,
C-Shell, TCSH, Korn Shell). Discuss their features, advantages, use case.
Bourne Shell (sh)
• Basic UNIX shell; supports pipes/redirects.
• Very stable and portable.
• Used for system/startup scripts.
Bash (Bourne Again Shell)
• Enhanced sh with history, job control, aliases.
• Most common Linux shell; powerful and user-friendly.
• Used for daily use and scrip ng.
C-Shell (csh)
• C-like syntax; built-in arithme c and history.
• Good for C programmers.
• Used in academic/interac ve environments.
TCSH (Enhanced csh)
• Improved csh with edi ng, autocomplete.
• More user-friendly.
• Used when csh compa bility + be er usability is needed.
Korn Shell (ksh)
• Mix of sh + csh features; strong scrip ng.
• Fast and enterprise-grade.
• Used in servers and professional scrip ng.
Q5)Explain the use of shell commands and scrip ng for process
management and file handling. Illustrate with examples of pipelining,
background/foreground execu on, and AWK programming.
• Shell commands manage processes: ps, kill, top, nice, jobs.
• Foreground execu on – shell waits.
python [Link]
• Background execu on – run with &.
python [Link] &
• Manage jobs using: jobs, fg %1, bg %1
• File handling commands: cp, rm, mv, touch
Examples: cp [Link] [Link] — rm fi[Link] — mv old new
• Pipelining (|) sends output of one command to another:
ps aux | grep python
• Combine pipe + file ops:
ls -l | sort -k5 (sort by size)
• Shell scrip ng automates tasks:
for f in *.txt; do
echo "Processing $f"
done
• AWK for pa ern scanning/data extrac on:
awk '{print $1, $3}' [Link]
• AWK filter example: awk '$3 > 50 {print $1, $2}' [Link]
Q4) Describe LR, SLR, LALR parsers. Compare their working principles,
table construc on, and suitability for different types of grammars.
• LR parsers: Bo om-up, use ACTION/GOTO tables; most powerful, use full LR(1)
items and handle almost all programming language grammars.
• SLR parsers: Use LR(0) items + FOLLOW sets; simplest and smallest tables, but
weakest (more conflicts).
• LALR parsers: Merge compa ble LR(1) states; tables are small like SLR but more
powerful (fewer conflicts).
• Table Sizes:
– LR → Largest (full LR(1) items)
– SLR → Smallest (LR(0) items)
– LALR → Medium (merged LR(1))
• Suitability:
– LR → Complex/industrial grammars
– SLR → Simple teaching grammars
– LALR → Most real compilers (e.g., YACC)
• Summary: LR = strongest, SLR = simplest, LALR = best prac cal balance.
Q4)Discuss intermediate code genera on in compilers. Explain three-
address code and other intermediate code forms with suitable
examples.
Intermediate Code Genera on (ICG) is a compiler phase that converts the source
program into a machine-independent, low-level representa on.
It helps in portability, because the same intermediate code can be used to
generate machine code for different architectures.
It separates machine-dependent and machine-independent op miza ons,
improving compiler design.
Three-Address Code (TAC) is the most common form of intermediate code where
each instruc on has at most three operands.
TAC uses temporary variables and breaks complex expressions into simple steps.
Example:
Expression: a + b * c
TAC:
o t1 = b * c
o t2 = a + t1
Quadruples are a representa on of TAC with four fields (operator, arg1, arg2,
result). Example: (+, a, t1, t2).
Triples store TAC without a result field; results are referred by index. Example: ( *,
b, c ) then ( +, a, (0) ).
Indirect Triples use a pointer table to refer to triples, making code modifica on
easier.
Pos ix (Reverse Polish Nota on) is another intermediate form where operators
appear a er operands. Example: a b c * +.
Syntax Trees / DAGs (Directed Acyclic Graphs) represent expressions structurally
and reduce redundant computa ons. Example: a DAG detects common
subexpressions like b * c appearing twice.