System Programming Question Bank

September 26, 2017 | Author: Shrunkhala Wankhede | Category: Parsing, Assembly Language, Computer Program, Scheduling (Computing), Command Line Interface
Share Embed Donate


Short Description

System Programming Question Bank...

Description

QUESTION BANK Subject Name:

System Programming

Subject Code:

CS-210

Branch:

IT (IV Sem)

1

Q1: What is the use of BALR instruction? Ans: BALR is an assembly language instruction to the computer to load a register with the next address and branch to the address in the second field. When the second operand is register o, the execution proceeds with the next instruction . it is useful because if the register dose not contain the address, BALR loads the base register, rather than showing program error.

Q2: Difference between pseudo-op and machine-op. Ans2:

A pseudo-op is an assembly language instruction that specifies an operation of the assembler i.e

about the base register & its contents e.g. USING instruction. On the other hand, a machine-op instruction. That represents a machine instruction to the assembler e.g. BR instruction is a machine-op instruction.

Q3: What is instruction counter? Ans: An instruction counter is a hardware memory device which denotes the location of the current instruction being executed. It is also called PC (program counter) or LC (location counter).

Q4: List the steps followed to design an assembler. Ans: The following are the steps followed to design an assembler:i)

Specify the problem: - Define symbol & literals and generate object program.

ii)

Specify data structures: - Establish database like mot (machine operation table), pot (pseudo operation table). Symbol table, base table etc.

iii)

Specify format of data structures:- Specify databases with name, length, binary, format and other relative fields.

iv)

Specify algorithm: - Define symbols & generate code.

v)

Look for modularity: Check the capability of the program to be subdivided into independent programming units.

vi)

Repeat steps 1 to 5 on modules.

Q5: What are advantages of direct linking loader? Ans: The following are the advantages of DLL:i)

It provides the programmer with multiple procedure segments & multiple data segments.

ii)

It provides endorsement referencing & accessing ability.

iii)

It allows independent translations of programs along with above benefits.

Q6: What is the use of IDE? Ans: IDE (Integrated Development Environment) is a software program that normally consists of a source code editor, a compiler, an interpreter, built in automation tools, debugger etc. The use of IDE is to create,

2

open,edit,view,save,compile and debug the applications. Thus, (IDE) assists computer programmers in developing software.

Q7: what are different types of cards produced by assembler? Ans:A card is a convenient unit of information, often of a variable length. A card may be a statement of a record on tape or drum. The assembler produces four types of cards in the object deck:i) ESDcard(External symbol dictionary ):-these cards contain information about all symbols that are defined and referenced at separate places in the program. ii)TXT(text )card:-These cards contain the actual object code translated version of the source program; iii)RLD(Relocation & Linkage Directory)card :-These cards contain information about those locations in the program whose contents depend on the address at which the program is placed. iv)END card:-The END card indicates the end of the object deck & specified the starting address for execution if the assembled routine is the main program.

Q8: Elimination of sub expression is performed in which phase? Explain briefly. Ans: The elimination of sub expression that appears more than once in a statement is a form machine independent optimization. It is done in OPTIMIZATION phase, before the matrix is used as a basis for code generation, other machine independent steps can be:i) compile time computation with constant operands. ii) Movement of computation with non varying operands, out of loop. iii) Use of Boolean algebra to minimize expression and computations. On the other hand reduction of space needed &execution time for the object program is a form of machine dependent optimization. It is typically done while generating code.

Q9: Name the various databases used in design of compiler? Ans: During the design of compiler, the databases actually form the lines of communication between the phases. The following is a list of databases used:i)Source code

vi)Reduction

ii) Uniform symbol table

vii) Matrix

iii) Terminal table

viii) Code productions

iv)Identifier table v) Literal table

ix)Assembly code x) Relocate Object code

3

Q10: Define relocation bits? Ans:-relocation bits are the bits indicating for a location of address. The assembler associates a bit with each address field or instruction. If this bit equals one, then the corresponding address field has to relocated, other wise not. This bits are included in the object deck, and are called Relocation bits

Q11: What is program counter? Ans:-An instruction counter is a hardware memory device which denotes the location of the current instruction being executed. It is also called PC (program counter) or LC(location counter).

Q12: What is the use of macro instructions? Ans: Macro instruction arguments are the extension of macro facility to enable modifications in the coding that replaces a macro call. The macro performs operation in the same way with a variable parameter, or argument. such a parameter is called macro instruction argument. It is specified in the macro line and distinguished by the ampersand (&), which is always its first character. e.g., MACRO

SOURCE

INCR

&ARG

A

1,&ARG

A

2,&ARG

.. INCR

DATA1 Use DATA1 as operand

. INCR

DATA2 UseDATA2 as operand

Q13: What are dummy arguments? Ans:-The parameters that appear in similar macro instruction sequence, so that the same function may be performed with a variable parameter or arguments, are known as dummy arguments. These are specified on the macro name line distinguished by the ampersand (&), which is always its first character.

Q14: What is the use of LTORG operation? Ans:-LTORG is a pseudo-op that tells the assembler to place the encountered literals at an earlier location. It is used for very long programs e.g., if an instruction contained 10,000 pieces of data ,it would be very difficult for the offset of the load instruction to reach the literals at the end of the program. In that case, LTROG is used to force the literals into the program before those particular instructions.

Q15: Define microkernel Ans: Micro kernel is a system kernel that runs itself in protected memory and all other processes in a separate memory so as to provide better stability. all non-essential components are removed from the kernel and

4

implemented as system and user level programs. this leaves behind a smaller kernel that provides various advantages like ease of probability and extension of operating system, better security and reliability.

Q16 - What is page fault? Ans -

If the “present bit” is set in the translation look aside buffer which is a high speed cache , then the page

is in the memory, and the processor can retrieve the frame number from the page table entry from the real address. The processor also updates the translation look aside buffer (TLB) to include this new page table entry. Finally, if the present bit is not set, then the desired page is not in the memory and a memory access fault, called the page fault, is issued. At this point we leave the field of activity or realm of the hardware and invoke the operating system, which loads the needed page and updates the page table.

Q 17: What is window editor? Ans: Windows editor is a application software that facilitates the user to develop document through the use of special features for editing, saving, formatting etc. it is a multipurpose text editor for the window system which combine the standard and easy to use GUI along with the functional requirement of the text. it provides intensive support in the form of text processor and other tools. MS-word is an example of window editor.

Q 18: What is a vi editor? Ans: Vi editor is a default full screen visual editor in UNIX OS. IT is a powerful editor helps to create and edit files very fast. It displays the content of file(ie text or prgm on the screen & allows the user to add, insert, delete, or changes part of the text).

Q 19 .What is a BUG? Ans :A bug is an error or defect in the software that causes a prgm to malfunction. A computer bug is an error, flaw, mistake, or a fault in a computer prgm that prevents it from working correctly and produces an incorrect result. Bugs often arise from errors made by the people in prgm’s source code or design due to syntax, logic, interlinking routines. Well written prgm contain relatively fewer bugs.

Q20: What is code generation? Ans: Code generation is a final phase of compilation process the purpose of this phase is to convert syntactically correct program into an appropriate series of instruction that could be executed by the machine. It takes as input the optimized intermediate codes in the form of matrix and generates as output the assembly code. For this, it takes into account the architecture of the machine and works in conjugation with symbol table and error handler phase.

5

Q21: Define time sharing? Ans: It refers to the allocation of computer resources in a time dependent fashion to several programs simultaneously. It is a special case of multiprogramming where a single CPU serves a no. of user at interactive terminals at the same time. The basic idea behind the time sharing systems is to allow all user program to have a brief share of CPU time in turns. The CPU is switched over the jobs on the bases of scheduling techniques (like round robin scheduling). The time interval given to each job is called time slice or time quantum. The switching of jobs is called context switching. Time sharing gives better utilization then multiprogramming.

Q 22: What is the meaning of finite automata? Ans: Finite automation or finite state machine (FSM) is a model of behavior composed of states, transitions and actions. A states stores information about the past i.e. it reflects the input changes from the system start to the present moment. A transition indicates a state change and is describe by a condition that must be fulfilled to enable the transition. An action is a description of an activity that is to be performed at a given moment.

Q 23: What is Lexical analysis? Ans:: IT is process Of taking an input string of characters (source code of a compiler program) and producing a sequence of symbols called lexical tokens. It is basically the passing of the source program into proper syntactic classes. The main function performed is the recognition of the basic elements (called tokens) and creation of uniform symbols. It build’s various tables like literal table, identifier table and symbol table.

Q 24::What is sub routine? Ans: Sub routine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code. Subroutine is a synonym for a function, method, procedure or a sub program. When a subroutine is called, the control transfers to its definition. After the execution of those lines of code, the control returns to the main program or function. The syntax of many programming languages includes support for creating self contained subroutines and for calling and returning from them.

Q 25:: What is an Assembly language?? Ans:: Assembly language is the second generation low level language used for writing computer prgms. It uses mnemonic abbreviations or words that are easier to remember than that of machine codes. The use of mnemonic in assembly language makes prgm easier, less error prone and less time consuming as compared to directly entering numeric machine codes. An assembly language prgm is translated into target computer’s machine code with the help of a utility prgm called assembler. Assemblers perform one to one (isomorphic) translation from mnemonic statements to machine instructions.

6

Q 26:: What is booting?? Ans Booting is a process of loading up the operating system files into the main memory or RAM. Once the OS is loaded it is ready for users to run applications. As soon as the computer is switched on the booting process automatically starts. Rebooting is the reloading of the operating system. Booting is of two types :- WARM & COLD booting. A COLD boot is when you turn the computer ON from an OFF position. A WARM boot is when you RESET a computer that is already ON.

Q 27: What are the different types of assemblers known to you? Ans Assembler is a program that receives the assembly language program as input & converts it into the corresponding object program or machine code .It also provide information to the loader. The assembler can be one of the following types:i)

Single pass assembler:-If the assembly process can be done within one pass , it is called single –pass or one-pass assembler.

ii)

Two-pass assembler:- If the assembly is done in two passes, then it is called two-pass assembler.

iii) Multi-pass assembler:- The translation of assembly language can also be done in several passes .Such assemblers are called multi-pass assemblers.

Q 28: Is it true that call leads to control to macro definition? Ans:-No, a micro call does not lead to transfer the control to macro definition. Instead of control transfer ,the body of macro is inserted into the object program . In other word, whenever there is a macro call , the macro processor replace it by the macro body and then the control is moved to the instruction .

Q 29:- What is an absolute loader? Ans:- ABSOLUTE LOADER:-In this scheme, the loader performs the function of loading the object program from secondary into the main memory for execution . The assembler places the object program on the card or the other secondary memory devices and also generates address relocation information for the other loader. Advantage of the scheme:-i) This make more core available to the user ,since assembler is not in the memory at a load time. ii) Absolute loader is very simple to implement. Disadvantage:-i) The programmer has to specify to assembler to the load the program. ii) The programmer has to remember the address of the sub-routines to be used in subroutines linkage.

Q 30:- What is intermediate code? Ans;- Once the syntactic construction is determined , the compiler generally generates an intermediate from of that source program, it is called intermediate code .The intermediate code can be represented in(i) Postfix notation (ii) Syntax tree (iii) Three address code.

7

Q31:- Name the step involved in the program execution given a source program. Ans:-The source program in high level language like C++, JAVA etc. The following are step of program execution:i) The HLL program or source code is compiled undergoing

Q32: What do you mean by debugging? Ans: Debugging is the process to find and remove errors in a program. A program can be tested step by step,i.e the contents of the registers and memory locations can be examined after the execution of every computation.

Q33: Give example of a language which uses more than one pass for compiling a program. Ans:C & C++ are the programming language that use more than one pass for compiling a program.

Q34: What is Bootstrapping? Ans: Bootstrapping is the process of initializing all components of the system i.e CPU,registers ,device controllers, contents of main memory etc. and then starting up of the system the initial program called bootstrap loader is stored in ROM at fixed location.

Q35: What do u mean by Multi processing OS? Ans: This technique involves the routing of different jobs to different processors. This means that processors are added up to work together to cope up with the increased number of users and to keep up the response time. The multiprocessor systems have two or more processors in close communication, sharing the computer bus and the clock, memory and peripheral devices.

Q36: In a two pass direct linking loading what is the function of pass 1? Ans :Pass 1 of two pass direct linking loader allocates segments and define symbols. The purpose of this pass is to assign a location to each symbol, and thus to define the values of all external symbols. Each symbol is assigned the next available location after the preceding segment in order to minimize the amount of storage required for the total program. Thus, pass 1 of DLL has a function of allocating segments and defining symbols.

Q37: At what point of time does the absolute loader scheme perform binding? Ans: Absolute loader perform binding before run-time. The whole linking and binding is performed and then the execution of program begins in this scheme.

8

Q38: Why is it necessary to reallocate a program in memory? Ans: It is necessary to reallocate a program in memory:i) To allocate memory space to program. ii) To resolve symbolic references between object decks. iii) To adjust all address dependent locations to corresponding allocated spaces. iv) To physically place the machine instructions and data into memory.

Q39: What do you mean by Time sharing? Ans: Time sharing refers to the allocation of computer resources in a time dependent fashion to several programs simultaneously. It is an extension of multiprogramming and multi-user system.

Q40: What do you mean by Multitasking? Ans: In multitasking, the resources are made to work continuously. The CPU Switches from one task to another for reading. This is called context switching. A multitasking OS supports two or more active processes simultaneously.

Q41: What do you mean by Parallel OS? Ans: When each statement of the program is routed to different processors the technique is called parallel processing. Parallel OS has two or more processors in close communication, sharing the computer bus.

Q42: What do you mean by loader? Ans:Loader is a program that loads object program from secondary memory into the main memory for execution of the program. The loader also performs the linking functions.

Q43: What is syntax error? Ans:Syntax errors are the mistakes or errors detectable by lexical analysis or syntax phase of the compiler. The errors generally occur due to wrong or misspelled words.

Q44: What is semantics error? Ans: Semantics errors are detected by the syntax analyzer during compilation process. Semantics refer to meaning of the line of code. The errors of declaration and scope cause semantics errors.

9

Q45: What is ambiguity? Ans:If a grammar produces more than one parse tree for the given input string,then this situation is called ambiguity and corresponding grammar is known as ambiguous grammar.

Q46: What do you mean by Debuggers? Ans:Debuggers are the system programs used to debug the programs. IT basically helps programmers to find errors in the program and trouble shoot them, statement by statement.

Q47: What do u mean by Text editor? Ans:A text editor is a utility program that facilitates the user to create, edit ,save and format text files .It has special commands for manipulating the text files efficiently. Q48: What do u mean by LEX? Ans: LEX:-It is a tool performs lexical analysis process. LEX helps to identify the basic valid elements called tokens out of the input stream. It scans the whole program and generates valid tokens which are a group of characters like keywords, constants, identifiers etc. LEX also keeps account of line numbers and white spaces. Q49: What do u mean by YACC? Ans: YACC:- YACC is a compiler tool for syntax analysis or parsing. It receives valid tokens from lexical analyzer and produces valid syntactical constructs as per the grammar of the source language and generates syntax errors otherwise. Q50: What is Swapping? Ans: The method of bringing a process into the main memory from the secondary memory and vice versa is called swapping. It is the job of operating system of most useful processes and keeping them in main memory. A process needs to be in memory only when executed. If the next ready-to-execute processes do not get free main memory, then the already executed processes are temporarily stored in secondary memory like disk etc. Thus the process of swapping provides the following advantages:i)Increased CPU utilization. ii)Increased multiprogramming. iii)Execution of programs larger than memory. However, the context time for swapping is an associated overhead.

10

Q51: What is Debugging? What are debugging techniques? Ans: Debugging is the process to find and remove errors in a program. A program can be tested step by stepi.e the contents of the registers and memory locations can be examined after the execution of every computation. The following are the debugging techniques: i) Single –step control ii) Break point method Q52: What is deadlock? What are the approaches for handling deadlocks? Ans: Deadlock is a state which occurs when two or more processes are waiting indefinitely for an events that can be caused only by one of the waiting processes. A deadlock occurs only when the below given four necessary conditions hold simultaneously in the system:1.

Mutual exclusion. 2. Hold and wait.

3. No pre-emption

4.Circular wait

Methods for handling deadlocks:i) Use some protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlock state. ii) Allow the system to enter a deadlock state, detect it and then recover. iii) Ignore the problem altogether and pretend that deadlocks never occur in the system Q53. What do you mean by multi window editor? Ans: Multi window editor is an editor which allows the user to open multiple windows. These are the editor with one application window and multiple documentation windows. For exemplum’s-Word is a multi window editor which has one application window to provide interface between the user application and the operating system. At the same time, multiple documentation windows can be opened within the single application window to provide features for editing, formatting, developing etc. Q54.What do u mean by static relocation? Ans: Relocation is the process of moving a program to a different location. Static Relocation refers to relocation at Compile time .All the routines and the main program is loaded into the main memory before execution . It

11

does not effect the external fragmentation. It does not bring about compaction of memory.

Q55: What are the features required in assembly language to build a two pass assembler? Ans: In order t o build a two pass assembler, an assembly language should support features like macroprocessing, file inclusion etc. Its definition should be independent of any particular hardware or operating system .Other features can be as follows:i) Interpretive mathematical semantics. ii) Axiomatic and Extensible definition. iii) Clear specification of problem iv) Appropriate data structures and algorithms. v) Modularity.

Q56: What do you mean by token? Ans: A token is a meaningful group of character set of programming language. it is the smallest unit of a statement that is delineated by blanks, operators after scanning program sequentially. These are of variable size. Examples of tokens are identifier names, keywords, constants. Q57: What do you mean by uniform symbol? Ans: These are the basic elements that are placed into tables with added information. These are the strings that consist of a syntactic class and a pointer to the table entry of associated basic element. These are of fixed size. Examples are identifier, literals, terminals symbols etc.

Q58: What do u mean by Shell? Ans:It refers to a utility program that comes with the UNIX system and acts as a COMMAND INTER PRETER for the kernel. It acts as an interface between the user and the kernel.Thus,the shell is an intermediately program that interprets the command typed in by the user at the terminal and translates them into commands shell commands. Commonly used shells are Borne and C shell.

12

Q59: What do you mean by Shell Script? Ans: It is a sequence of shell commands stored in a file for later execution with single command. These are just like batch files in DOS but shell scripts are much more powerful. These allow I/O can manipulate variables and consist of powerful control and iteration constructs that make programming possible. Q60: What are the different problems with the layered OS model? Ans:i) Inappropriate definition of layers. ii) Poor interaction between processes. iii) Added overheads associated with system. iv) Less efficiency. v) Error prone proposition. vi) Expensive changes related to layers. Q61: What are the different LPDT widely used in practice? Ans:The LPDT widely used are a listed below:•

ALE(Attribute Logic Engine )



CGPARSER



CHARON



Cone



ELIZA



ENGLEX Q62: What is Spooling? Ans:A spool(Simultaneous Peripheral Operation On Line )is a buffer that holds output for a device, such as a printer that cannot accept interleaved data streams. Spooling is a technique in which secondary storage is used to spool the output files as a queue. The spooling system copies the queued spool file to the printer, one at a time. Thus, spooling is a technique to reduce speed mismatch and intern , the idle time of the CPU.

13

Q63: List the advantages of binding at load time over binding at assembly time. Ans: The advantages of binding at load time over binding at assembly time are: i) Better utilization of memory:- Due to binding at load time, there is no wastage of memory due to unused instructions & linkages. So, the memory is better utilized with only needed links in it. ii)Increased throughput:-The CPU is better utilized and thus it increases the throughput. iii) Execution of programs larger than available memory is possible. iv) Pre-emptive ness of processes leads to better multiprogramming. Q64: What is loading of a program? Ans: Loading is the process of preparing the object deck for execution and moving it to the main memory for execution. It refers to the following four functions:i) Allocation:-Allocating space in memory for the programs. ii) Linking:-Resolving symbolic references between object decks. iii) Relocation:-Adjusting all address dependent locations to corresponding allocated spaces. iv) Loading:-Physically placing the machine instructions and data into main memory for execution.

Q65: What is look ahead pointer? Ans:-Look Ahead Pointer: - Look Ahead Pointer is a variable used in lexical analysis that stores the address of next instruction. It also points towards next instruction during compilation. Q66: What is symbol table? Ans:- Symbol table is a data structure used by compilers and assemblers to keep account of the attributes of the identifier and other information. The attributes may be type, value, scope, address etc. It performs the function of bookkeeping. It is composed of multiple word entries in a fixed format. There is a special string called KEY that distinguishes each entry from the others. This unique key is matched during a search in symbol table.

14

Q67:At What point of time does direct linking loader(DLL) perform binding? Ans: DLL performs binding of all subroutines right before the time of execution .It links together all the object module and the necessary libraries to produce as output an EBP, which is Executable Binary Program. Q68: What are the various errors seen in a compiler? Explain. Ans:i)Syntax errors like invalid characters, misspelled identifiers etc. ii) Syntactic errors due to out of scope definition and type mismatch. iii) Operands with incompatible types create intermediate code errors iv) Code optimization errors like never used statements. v) Code generation errors like a constant too large to fit in a word of target machine. vi) Symbol table errors like multiple declarations of an identifier with contradictory attributes. Q69: What is parse tree? Ans: Parse trees are the output of syntax analysis phase of compiler. parse tree is a graphical representation for derivation that filters out the choice regarding replacement order. The valid token are received and checked to generate corresponding syntactic constructs against the grammar, otherwise syntactical errors are generated. So, parse tree is the representation of valid tokens in a specific order, produced by syntax analyzer. Q70: What is the need of grammar? Ans: The grammars are needed to specify the syntactical structures of a programming language. The reductions and derivations help to find ambiguity. Q71: What are Compiler writing tools? Ans: The following are the compiler writing tools: i) LEX:-It is a tool performs lexical analysis process. LEX helps to identify the basic valid elements called tokens out of the input stream. It scans the whole program and generates valid tokens which are a group of characters like keywords, constants, identifiers etc. LEX also keeps account of line numbers and white spaces.

15

ii) YACC: - YACC is a compiler tool for syntax analysis or parsing. It receives valid tokens from lexical analyzer and produces valid syntactical constructs as per the grammar of the source language and generates syntax errors otherwise. Q72What do u mean by dynamic relocation? Ans: Relocation is the process of moving a program to a different location. Dynamic Relocation refers to relocation at execution time .Routine are not loaded until it is called. All routine are kept on disc in a relocated load format. It brings out compaction and better memory space utilization. It reduces external fragmentation. Q73: What do you mean by text editor? Ans: A text editor is a utility program that facilitates the user to create, edit ,save and format text files. It has special commands for manipulating the text files efficiently. Q74: What do you mean by pseudo-op? Ans. A pseudo-op is an assembly language instruction that specifies an operation of the assembler i.e about the base register & its contents e.g. USING instruction.

Q75: What do you mean by machine-op instruction? Ans. A machine-op instruction. That represents a machine instruction to the assembler e.g. BR instruction is a machine-op instruction. Q76:What is a Parser ? Ans:A Parser for a Grammar is a program which takes in the Language string as it's input and produces either a corresponding Parse tree or an Error. Q77: What is the Syntax of a Language? Ans: The Rules which tells whether a string is a valid Program or not are called the Syntax.

16

Q78: What is the Semantics of a Language? Ans: The Rules which gives meaning to programs are called the Semantics of a Language. Q79: What are tokens? Ans: When a string representing a program is broken into sequence of substrings, such that each substring represents a constant, identifier, operator, keyword etc of the language, these substrings are called the tokens of the Language. Q80: What is the Lexical Analysis ? Ans: The Function of a lexical Analyzer is to read the input stream representing the Source program, one character at a time and to translate it into valid tokens. Q81: How can we represent a token in a language ? Ans: The Tokens in a Language are represented by a set of Regular Expressions. A regular expression specifies a set of strings to be matched. It contains text characters and operator characters. The Advantage of using regular expression is that a recognizer can be automatically generated. Q82: How are the tokens recognized? Ans: The tokens which are represented by an Regular Expressions are recognized in an input string by means of a state transition Diagram and Finite Automata.

Q83: Are Lexical Analysis and Parsing two different Passes ? Ans: These two can form two different passes of a Parser. The Lexical analysis can store all the recognized tokens in an intermediate file and give it to the Parser as an input. However it is more convenient to have the lexical Analyzer as a co-routine or a subroutine which the Parser calls whenever it requires a token. Q84: What are the Advantages of using Context-Free grammars? Ans: It is precise and easy to understand. It is easier to determine syntactic ambiguities and conflicts in the grammar.

17

Q85: If Context-free grammars can represent every regular expression ,Why do one needs R.E at all? Ans: 1 Regular Expression are Simpler than Context-free grammars. 2 It is easier to construct a recognizer for R.E than Context-Free grammar. 3 Breaking the Syntactic structure into Lexical & non-Lexical parts provide better front end for the Parser. 4 R.E are most powerful in describing the lexical constructs like identifiers, keywords etc while Context-free grammars in representing the nested or block structures of the Language. Q86: What are the Parse Trees ? Ans: Parse trees are the Graphical representation of the grammar which filters out the choice for replacement order of the Production rules. e.g. for a production P->ABC the parse tree would be P / \\ /

\ \

A

B C

Q87: What are Terminals and non-Terminals in a grammar ? Ans: Terminals: - All the basic symbols or tokens of which the language is composed of are called Terminals. In a Parse Tree the Leafs represents the Terminal Symbol. Non-Terminals:- These are syntactic variables in the grammar which represents a set of strings the grammar is composed of. In a Parse tree all the inner nodes represents the Non-Terminal symbols. Q88: What are Ambiguous Grammars? Ans: A Grammar that produces more than one Parse Tree for the same sentences or the Production rules in a grammar is said to be ambiguous. e.g. consider a simple mathematical expression E->E*E This can have two Parse tree according to assocciativity of the operator '*'

*

E

E

/ \

/ \

E

E

*

18

/ \ E

/\ E

E E

Q89: What is bottom up Parsing ? Ans: The Parsing method in which the Parse tree is constructed from the input language string begining from the leaves and going up to the root node. Bottom-Up parsing is also called shift-reduce parsing due to it's implementation. The YACC supports shift-reduce parsing. e.g. Suppose there is a grammar G having a production E E->E*E and an input string x*y. The left hand side of any production is called Handles. Thus the handle for this example is E. The shift action is simply pushing an input symbol on a stack. When the R.H.S of a production is matched the stack elements are popped and replaced by the corresponding Handle. This is the reduce action. Q90: What is the need of Operator precedence ? Ans: The shift reduce Parsing has a basic limitation. A grammar which can represent a left-sentential parse tree as well as right-sentential parse tree cannot be handled by shift reduce parsing. Such a grammar ought to have two non-terminals in the production rule. So the Terminal sandwiched between these two non-terminals must have some associativity and precedence. This will help the parser to understand which non-terminal would be expanded first. Q91: What is a LR Parser ? Ans: The LR means Left-to- Right signifying the parser which reads the input string from left to right. An LR parser can be written for almost all Programming constructs. An LR parser consists of two parts: - Driver Routine & Parsing Table. The Driver routine is same for all the Parsers only the Parsing Table changes. The Parsing Table is essentially a form of representing the State- Transition Diagram for the language. It consists of the entries for all possible States and the input symbols. In each state there in a predetermined next state depending upon the input symbol. If there is any duplicate entry or two next states for the same symbol, then there is an ambiguity in the grammar. Q92: What is LALR Parser? Ans: LALR is Look-ahead LR parser. It differs from LR in the fact that it will look ahead one symbol in the input string before going for a reduce action. Look- ahead helps in knowing if the complete rule has been matched or not. E.g. Consider a grammar G with production

19

P->AB|ABC When the Parser shifts the Symbol B it can reduce to P. But if the next Symbol was C then it has not matched the complete rule. A LALR parser will shift one extra token and then take a decision to reduce or shift. Q93 -What is dynamic loading? Ans - To obtain the better memory-utilization, the dynamic loading is used. With the dynamic loading, a routine is not loaded until it is called. All the routines are kept on the disk in a relocatable load format. The main program is loaded into the memory and is executed. When a routine needs to call another routine, the calling routine first check to see whether the other routine has been loaded. If not, the relocatable linking loader is called to load the desired routine into the memory and to update the program’s address tables to reflect this change. Then control is passed to newly loaded routine.

Q94 - What is swapping? Ans -Swapping is defined as a process which can be swapped temporarily out of the memory to a backing store and then brought back into the memory for continued execution. For e.g. assume a multiprogramming environment with a round-robin CPU-scheduling algorithm. When the quantum expires, the memory manager will start to swap out the process that just finished and to swap another process into the memory space that has been freed. When each process finishes its quantum, it will be swapped with the another process.

Q95. Explain Fragmentation. Ans Consider a multiple partition allocation scheme with a hole of 18,464 bytes. Suppose the next process requests 18,462 bytes. If we allocate exactly the requested block, we are left with a hole of 2 bytes. The overhead to keep track of this hole will be substantially larger than the hole itself. The general approach is to break the physical memory into fixed sized blocks, and allocate memory in unit of block sizes. With this, the memory allocated to a process may be slightly larger than the requested memory.

Q.96 Explain internal and external fragmentation? Ans. A multiprogrammed system will generally perform more efficiently if it has a higher level of multiprogramming for a given set of processes. We can increase multiprogramming level only by packing more processes into memory. To accomplish this task we must reduce memory waste or fragmentation. System with variable size allocation units such as multi partition scheme and segmentation suffer from external fragmentation. System with fixed size allocation such as single partition scheme and paging suffer from internal fragmentation.

Q.97 Distinguish between preemptive and Non-preemptive scheduling? Ans. CPU scheduling may take place under the following four circumstances: 1. When a process switches from the running state to waiting state.

20

2. When a process switches from the running state to ready state. 3. When a process switches from the waiting state to ready state. 4. When a process terminates. When scheduling takes place only under circumstances 1 and 4, we say the scheduling scheme in Nonpreemptive otherwise it is preemptive Under Non-preemptive scheduling once the CPU has been allocated to a process the process keeps the CPU either by terminating or by switching to the wait state. This scheduling method is used by the Microsoft window 3.1 and by apple machnitosh operating system. It is the only method that can be used on certain hardware platforms; because of it does not require the special hardware needed for preemptive scheduling.

Q98 what are two different access methods? Ans. Files store information, when it is used the information must be accessed and read into computer memory. The information in the file can be accessed in several ways. •

Sequential access: the simplest access method is sequential access. Information in the file is processed in order, one record after the other. This mode of access is by far the most common editors and compilers usually access files in this fashion.



Direct access: another method is direct access. A file is made up of fixed length logical records that allow programs to read and write records rapidly in no particular order. The direct access method is based on a disk model of a file.

Q99. Explain scan scheduling. Ans. In Scan scheduling, the disk arm starts at one end of the disk, and moves to the other end, servicing requests as it reaches each cylinder. At the other end of the cylinder, the direction of the head is reversed, and servicing continues. The head continuously scans back and forth of the head, it will be serviced almost immediately; a request just arriving behind the head will have to wait till the arm moves to the end of the disk, reverses direction and comes back. It is also sometimes called the Elevator Algorithm.

Q100 - Define CPU scheduler and job scheduler? Ans - The long-term scheduler, or job scheduler, selects processes from the pool of mass storage devices typically a disk and loads them into memory for execution. The long-term scheduler executes much less frequency, the long-term scheduler controls the multiprogramming and thus, the long-term scheduler may be needed to be invoked only when a process leaves the system.

21

The short-term, or the CPU scheduler, selects from among the processes that are ready to execute and allocates the CPU one of them. The short term scheduler must select a new process for the CPU frequently. It executes at least once every 100 milliseconds, because of short time between the execution it must be fast .if it takes 10 milliseconds to decide to executes a process for 100 millisecond, and then 9 percent of the CPU is being used i.e. wasted in scheduling the work.

22

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF