Thursday 14 September 2017

JANUARY 2017 - PAPER II



JANUARY 2017 – PAPER II

OPERATING SYSTEMS

37. In a paging system, it takes 30 ns to search translation Look-a-side Buffer (TLB) and 90 ns to access the main memory. If the TLB hit ratio is 70%, the effective memory access time is 

(1) 48ns
(2) 147ns
(3) 120ns
(4) 84ns

Ans :- 2

Explanation:-

This is a paragraph taken from “Operating systems” book by Silberschatz.



In order to calculate the effective memory access time, we are going to apply the explanation given in the above mentioned book.

A 70 percent ratio means that we find the desired page number in the TLB 70 percent of the time. If it takes 30 ns to search the TLB and 90 ns to access memory, then a mapped-memory access takes 30+90 ns when the page number is in the TLB. If we fail to find the page number in the TLB(30), then we must first access memory for the page table and frame number(90ns) and then access the desired byte in the memory(90ns), for a total of 210ns. To find the effective memory access time, we weight each case by its probability,

Effective access time = 0.70 X 120 + 0.30 X 210

                                  = 84 + 63 = 147ns

So, the correct answer is 147ns. The option is 2.

DIFFERENCE BETWEEN C,C++ AND JAVA



DIFFERENCES BETWEEN C,C++ AND JAVA IN A NUTSHELL

S.NO
C
C++
JAVA
1.
Structured programming language
Object-oriented programming language
Object-oriented programming language
2.
Compiled
Compiled
Compiled and interpreted
3.
32 keywords
Eg:- case, char
60 keywords
Eg:- class, protected
50 keywords
Eg:- interface, extends
4.
Rules for naming identifier
1.      Should begin with alphabet
2.      Can have numbers,underscore
3.      Keywords cannot used as identifiers
Rules for naming identifier
1.      Should begin with alphabet
2.      Can have numbers,underscore
3.      Keywords cannot used as identifiers
Rules for naming identifier
1.      Can  begin with alphabet, underscore or dollar symbol. But cannot begin with a  number
2.      Keywords cannot used as identifiers

5.
Comments:- /*….*/ (multi line comment),   //(single line comment)
Comments:- /*….*/ (multi line comment),   //(single line comment)
Comments:- /*….*/ (multi line comment),   //(single line comment), /** …. */(documentation comment)
6.
Data types :- int,char,float,double,void
Data types :- int,char,float,double,void
Data types:-
byte,short,int,long,
float,double,
char,boolean

7.
Bitwise shift operators are : >>(right shift),<<(left shift)
Bitwise shift operators are : >>(right shift),<<(left shift)
Bitwise shift operators are : >>(right shift),<<(left shift),>>>(triple right shift operator)
8.
Char is 8 bits wide
Char is 8 bits wide
Java uses Unicode to represent characters. It is 16 bits wide.
9.
Preprocessor directives allowed
Eg:- #include,#define
Preprocessor directives allowed
Eg:- #include,#define
No preprocessor directives
10.
Variables need not be initialized before using it
Variables need not be initialized before using it
Variables must be initialized before using it
11.
Array should be declared mentioning its size
Eg:- int num[10];
Array should be declared mentioning its size
Eg:- int num[10];
Arrays are declared without mentioning its size.
int num[];
 num=new int[10] (or)
int num[]=new int[10];
12.
Explicit string data type not available
Explicit string data type not available
String data type available in java. It is a class
13.
Supports pointers
Supports pointers
Does not support pointers
14.
Structures and unions available
Structures and unions available
Structures and unions not available
15.
-
Supports operator overloading
Does not support operator overloading
16.
-
Programs can be written in c++ without using a class
All the code in java program needs to be written in one or more classes
17.
Global variables and functions are allowed
Global variables and functions are allowed
No global variables or functions
18.
-
Allows default arguments in functions
Not allowed in java
19.
-
Supports multiple inheritance
Multiple inheritance not supported
20.
-
Supports constructors and destructors
Supports constructors, no destructors
21.
Supports typedef
Supports typedef
Does not support typedef
22.
Unsigned integers can be declared
Unsigned integers can be declared
No unsigned integers
23.
Allows goto
Allows goto
Does not allow goto
24.
-
delete operator available
No delete operator
25.
-
Objects may be passed by value or by reference
Objects are passed by reference only in Java