Wednesday, 26 September 2012

OS Interview Questions-6


1.What are the deadlock avoidance algorithms?
Ans: A dead lock avoidance algorithm dynamically examines the resource-allocation state to ensure that a circular wait condition can never exist. The resource allocation state is defined by the number of available and allocated resources, and the maximum demand of the process.There are two algorithms:
1. Resource allocation graph algorithm
2. Banker’s algorithm
a. Safety algorithm
b. Resource request algorithm

2. What are the basic functions of an operating system?
Ans : Operating system controls and coordinates the use of the hardware among the various applications programs for various uses. Operating system acts as resource allocator and manager. Since there are many possibly conflicting requests for resources the operating system must decide which requests are allocated resources to operating the computer system efficiently and fairly. Also operating system is control program which controls the user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices.

3.Explain briefly about, processor, assembler, compiler, loader, linker and the functions executed by them.
Ans :
Processor:–A processor is the part a computer system that executes instructions .It is also called a CPU
Assembler: — An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer’s processor can use to perform its basic operations. Some people call these instructions assembler language and others use the term assembly language.
Compiler: — A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or “code” that a computer’s processor uses. Typically, a programmer writes language statements in a language such as Pascal or C one line at a time using an editor. The file that is created contains what are called the source statements. The programmer then runs the appropriate language compiler, specifying the name of the file that contains the source statements.
Loader:–In a computer operating system, a loader is a component that locates a given program (which can be an application or, in some cases, part of the operating system itself) in offline storage (such as a hard disk), loads it into main storage (in a personal computer, it’s called random access memory), and gives that program control of the compute
Linker: — Linker performs the linking of libraries with the object code to make the object code into an executable machine code.

4. What is a Real-Time System?
Ans : A real time process is a process that must respond to the events within a certain time period. A real time operating system is an operating system that can run real time processes successfully

5. What is the difference between Hard and Soft real-time systems?
Ans : A hard real-time system guarantees that critical tasks complete on time. This goal requires that all delays in the system be bounded from the retrieval of the stored data to the time that it takes the operating system to finish any request made of it. 
A soft real time system where a critical real-time task gets priority over other tasks and retains that priority until it completes. As in hard real time systems kernel delays need to be bounded

6. What is virtual memory?
Ans : A virtual memory is hardware technique where the system appears to have more memory that it actually does. This is done by time-sharing, the physical memory and storage parts of the memory one disk when they are not actively being used

7. What is cache memory?
Ans : Cache memory is random access memory (RAM) that a computer microprocessor can access more quickly than it can access regular RAM. As the microprocessor processes data, it looks first in the cache memory and if it finds the data there (from a previous reading of data), it does not have to do the more time-consuming reading of data

8.Differentiate between Complier and Interpreter?
Ans : An interpreter reads one instruction at a time and carries out the actions implied by that instruction. It does not perform any translation. But a compiler translates the entire instructions.

9.What are different tasks of Lexical Analysis?
Ans : The purpose of the lexical analyzer is to partition the input text, delivering a sequence of comments and basic symbols. Comments are character sequences to be ignored, while basic symbols are character sequences that correspond to terminal symbols of the grammar defining the phrase structure of the input

10. Why paging is used?
Ans : Paging is solution to external fragmentation problem which is to permit the logical address space of a process to be noncontiguous, thus allowing a process to be allocating physical memory wherever the latter is available.

UNIX Interview Questions-7


61. What are the phases of swapping a page from the memory?
Ans: Page stealer finds the page eligible for swapping and places the page number in the list of pages to be swapped. Kernel copies the page to a swap device when necessary and clears the valid bit in the page table entry, decrements the pfdata reference count, and places the pfdata table entry at the end of the free list if its reference count is 0.

62. What is page fault? Its types?
Ans: Page fault refers to the situation of not having a page in the main memory when any process references it. There are two types of page fault :
- Validity fault,
- Protection fault.

63. In what way the Fault Handlers and the Interrupt handlers are different?
Ans: Fault handlers are also an interrupt handler with an exception that the interrupt handlers cannot sleep. Fault handlers sleep in the context of the process that caused the memory fault. The fault refers to the running process and no arbitrary processes are put to sleep.

64. What is validity fault?
Ans: If a process referring a page in the main memory whose valid bit is not set, it results in validity fault. The valid bit is not set for those pages:
- that are outside the virtual address space of a process,
- that are the part of the virtual address space of the process but no physical address is assigned to it.

65. What does the swapping system do if it identifies the illegal page for swapping?
Ans: If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a “Segmentation violation” signal to the offending process. This happens when the swapping system identifies any invalid memory reference.

66. What are states that the page can be in, after causing a page fault?
Ans: On a swap device and not in memory, On the free page list in the main memory, In an executable file, Marked “demand zero”, Marked “demand fill”.

67. In what way the validity fault handler concludes?
Ans: It sets the valid bit of the page by clearing the modify bit. It recalculates the process priority.

68. At what mode the fault handler executes?
Ans: At the Kernel Mode.

69. What do you mean by the protection fault?
Ans: Protection fault refers to the process accessing the pages, which do not have the access permission. A process also incur the protection fault when it attempts to write a page whose copy on write bit was set during the fork( ) system call.

70. How the Kernel handles the copy on write bit of a page, when the bit is set?
Ans: In situations like, where the copy on write bit of a page is set and that page is shared by more than one process, the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page. After copying the Kernel updates the page table entry with the new page number. Then Kernel decrements the reference count of the old pfdata table entry. In cases like, where the copy on write bit is set and no processes are sharing the page, the Kernel allows the physical page to be reused by the processes. By doing so, it clears the copy on write bit and disassociates the page from its disk copy (if one exists), because other process may share the disk copy. Then it removes the pfdata table entry from the page-queue as the new copy of the virtual page is not on the swap device. It decrements the swap-use count for the page and if count drops to 0, frees the swap space. 

Tuesday, 25 September 2012

TCS Placement Paper 2012

About TCS:-
Tata Consultancy Services - TCS is the pioneer of software services in India and is headquartered in Mumbai. With over 45,000 consultants working from offices and development centers spread all over the country, TCS works with global and Indian companies to create real business results. Apart from the development centers, TCS has centers of excellence and innovation labs that strengthen TCS’ ability to deliver innovative business solutions.

FAQ:

1. Which Is The Smallest No Divides 2880 And Gives A Perfect Square?

A.1 B.2 C.5 D.6

Ans: C

2. Two Bowls Are Taken, One Contains Water And Another Contains Tea  Equal Amount . One Spoon Of Water From 1st Is Added To Second Bowl And Mixed Well, And A Spoon Of Mixture Is Taken From Second Bowl And Added To The 1st Bowl. Which Statement Will Hold Good For The Above?
{
Thought Process :
Water Bowl Tea Bowl
100 100
90w (+10w= Spoon Volume) 100tea+10water
90w+ (10*10/11)Tea+ 10/11 W 100t- (10*10/11) T
+ 10w- 10/11w
(1st Bowl’s Water Volume Is Equal To 2nd Bowls Tea Volume)

3. Form 8 Digit Numbers From By Using 1, 2,3,4,5 With Repetition Is Allowed And Must Be Divisible By 4?

A.31250 B.97656 C.78125 D.97657

Ans: C

4. Rearrange And Categorize The Word ‘Rapeteka’?

Ans: Bird

5. One Problem On (785^3-235^3)/(785^2+785*235+235^2)

Ans: You Are Free To Carry A Calculator With You But You Should Not Use It To Solve This Kind Of Problem. Because It Is Simple:

A3-b3 / A2+ab+b2

Ans Is : A-b Here 785-235= 550 That's It.

6. In School There Are Some Bicycles And 4 Wheeler Wagons. One Tuesday There Are 190 Wheels In The Campus. How Many Bicycles Are There?

Ans: 15

Thought Process : B*2+w*4=190 I.E. , B+2w=95 Now See U Can Not Solve 2 Unknowns From 1 Equation, So Just Plot Options Here To Get The Right Answer And Verify If You Are Getting Integers As Values Of B And W.

7. There Are Two Persons Paul And Jay .Paul Lies On Monday, Tuesday, Wednesday And The Remaining Days He Speaks Truth. Jay Lies On Thursday, Friday, Saturday And The Remaining Days He Speaks Truth. Once They Meet Each Other, In Their Conversation Paul Says That Yesterday Is The Day One Among Those I Lie. Jay Also Says That Yesterday I Also Lie. What Is That Day?

A) Sunday. B) Tuesday. C) Thursday. D) Wednesday

[Thought Process: Now This Day Cannot Be Sunday Because In Monday Paul Speaks Truth And Sunday Everyone Tells Truth. So It Must Be Weekdays. Again, Tuesday Can Not Possible Because Monday And Tuesday Paul Speaks Truth. In Case Of Thrust Day, Paul Speaks Lie And Wednesday He Speaks True. And Joy Speaks Truth In Thursday And He Speak Lies In Wednesday. So, Thursday Is The Answer.

8. A Father Has 7 Penny’s With Him And 1 Water Melon Is For 1p, 2chickoos For 1p, 3 Grapes Foe 1p. He Has Three Sons. How Can He Share The Fruits Equally?

Ans: 1 Watermelon, 2chickoos, 1grape

9. (1/2) Of A Number Is 3 Times More Than The (1/6) Of The Same Number?

Ans: 9

10. There Are Two Pipes A And B. If A Filled 10 Liters In Hour B Can Fills 20 Liters In Same Time. Likewise B Can Fill 10, 20, 40, 80,160…. If B Filled In (1/16) Th Of A Tank In 3 Hours, How Much Time Will It Take To Fill Completely?

Ans: 7 Hours

11.A certain pump can drain a full 375-gallon tank in 15 minutes. At this rate, how many more minutes would it take to drain a full 600-gallon tank?

(A) 9 (B) 15 (C) 18 (D) 24 (E) 25

12. If n is an even integer, which of the following must be an odd integer?

(A) 3n-2 (B) 3(n+1) (C)n-2 (D)n/3 (E)n^2

13. Cindy has a collection of 80 records. If 40 percent of her records are jazz records, and the rest are blues records, how many blues records does she have?

(A) 32
(B) 40
(C) 42
(D) 48
(E) 50

14. Express 2,750,389 in scientific notation.

(A) 27.50389 x 105
(B) 275.0389 x 103
(C) 27.50389 x 106
(D) 0.2750389 x 107
(E) 2.750389 x 106

15. A rectangle and a triangle have equal areas. The length of the rectangle is 12 inches, and its width is 8 inches. If the base of the triangle is 32 inches, what is the length, in inches, of the altitude drawn to the base?

(A) 6
(B) 8
(C) 9
(D) 12
(E) 16

16. If the area of a triangle is 24 and its base is 6, what is the length of the altitude to that base?

(A)3 (B)6 (C)8 (D)10 (E)unknown

17.Lenny's average score after 3 tests is 88. What score on the 4th test would bring Lenny's average up to exactly 90?

(A)92 (B)93 (C)94 (D)95 (E)96

18. If an integer is divisible by 6 and by 9, then the integer must be divisible by which of the following?

A. 12
B. 18
C. 24
D. 36
E. 54

19.If Jeff and Jimmy have less than 22 dollars between them, and Jeff has 8 dollars, which of the following could be the number of dollars that Jimmy has?
I.12 II. 14 III. 16

A. I only
B. III only
C. I & III.
D. I & II
E. Neither I, II, nor III are correct

20.Stephanie drove at an average rate of 50 miles per hour for two hours and then increased her average rate by 50% for the next 3 hours. Her average rate of speed for the 5 hours was t miles per hour. What is the value of t?

A. 55 mph
B. 60 mph
C. 65 mph
D. 70 mph
E. 75 mph

21. How many complete tanks of water, each with a capacity of 3 cubic meters, are needed to fill an empty cylindrical tank whose height is 3 meters and whose base has a radius of 2 meters?

A) 12 B) 13 C) 14 D) 15 E) 16

22. Any serious policy discussion about acceptable levels of risk in connection with explosions is not well served if the participants fail to use the word “explosion” and use the phrase “energetic disassembly” instead. In fact, the word “explosion” elicits desirable reactions, such as a heightened level of attention, whereas the substitute phrase does not. Therefore, of the two terms, “explosion” is the one that should be used throughout discussions of this sort.

Which of the following is an assumption on which the argument above depends?

(A) In the kind of discussion at issue, the advantages of desirable reactions to the term “explosion” outweigh the drawbacks, if any, arising from undesirable reactions to that term.
(B) The phrase “energetic disassembly” has not so far been used as a substitute for the word “explosion” in the kind of discussion at issue.
(C) In any serious policy discussion, what is said by the participants is more important than how it is put into words.
(D) The only reason that people would have for using “energetic disassembly” in place of “explosion” is to render impossible any serious policy discussion concerning explosions.
(E) The phrase “energetic disassembly” is not necessarily out of place in describing a controlled rather than an accidental explosion

23. A certain shade of gray paint is obtained by mixing 3 parts of white paint with 5 parts of black paint. If 2 gallons of the mixture is needed and the individual colors can be purchased only in one-gallon or half- gallon cans, what is the least amount of paint, in gallons, that must be purchased in order to measure out the portions needed for the mixture?

(A) 2 (B) 2 ½ (C) 3 (D) 3 ½ (E) 4

24. To buy a computer system, a customer can choose one of 4 monitors, one of 2 keyboards, one of 4 computers and one of 3 printers. Determine the number of possible systems that a customer can choose from.
(A) 96 (B)98 (C)98.5 (D) 94 (E)100

25. A student can select one of 6 different mathematics books, one of 3 different chemistry books and one of 4 different science books. In how many different ways can a student select a book of mathematics, a book of chemistry and a book of science?

A) 14 (B)12 (C)72 (D) 74 (E)76


UNIX Commands


1. Files

1.1. Filename Substitution
Wild Cards                                                                                 ? *
Character Class (c is any single character)                                   [c…]
Range                                                                                         [c-c]
Home Directory                                                                          ~
Home Directory of Another User                                                 ~user
List Files in Current Directory                                                      ls [-l]
List Hidden Files                                                                         ls -[l]a

1.2. File Manipulation
Display File Contents                                                                 cat filename
Copy                                                                                         cp source destination
Move (Rename)                                                                         mv oldname newname
Remove (Delete)                                                                        rm filename
Create or Modify file                                                                  pico filename

1.3. File Properties
Seeing Permissions                                                                     ls -l filename
Changing Permissions                                                                chmod nnn filename
                                                                                                 chmod c=p…[,c=p…] filename
n, a digit from 0 to 7, sets the access level for the user (owner), group, and others (public), respectively.
c is one of: u–user; g–group, o–others, or a–all. p is one of: r–read
access, w–write access, or x–execute access.
Setting Default Permissions                                                       umask ugo
ugo is a (3-digit) number. Each digit restricts the default permissions for the user, group, and others, respectively.
Changing Modification Time                                                     touch filename
Making Links                                                                           ln [-s] oldname newname
Seeing File Types                                                                     ls -F

1.4. Displaying a File with less
Run less                                                                                   less filename
Next line                                                                                  RETURN
Next Page                                                                                SPACE
Previous line                                                                             k
Previous Page                                                                           b

1.5. Directories
Change Directory                                                                      cd directory
Make New Directory                                                                mkdir directory
Remove Directory                                                                     rmdir directory
Print Working (Show Current) Directory                                    pwd

List of Sports Terms


 AtheleticsRelay, Photofinish, Track, Lane, Hurdles, Shotput, Discuss Throw, Hammar Throw, Triple Jump, High Jump, Cross Country, etc.

 BadmintonShuttle cock, Service court, Fore hand, Back Hand, Smash, Hit, Drop, Net, Love, Double fault, etc.
 BaseballPinching, Home run, Base runner, Throw, Perfect game, Strike, Put out, etc.

 BasketballFree throw, Technical foul, Common foul, Under head, Over head, etc.

 BridgeMaster point, Perfect deals, Gland slam, Dummy, Trump, etc.

 Billiards & SnookerPull, Cue, Hit, Object ball, Break shot, Scoring, Cushion billiards, etc.

 BoxingKnock out, Round, Ring Stoppage, Punch, Upper-cut, Kidney punch, Timing, Foot work, etc.

 ChessE. L. O. rating, international master, Grand master, Gambit, Kings Indian Defence, etc.

 CyclingSprint, Time trial, Point race, Trackrace, etc.

 CricketToss, Run, Wicket, Pitch, Stump, Bails, Crease, Pavalion, Gloves, Wicket Keeper, Over, Maiden over, Followon, Rubber, Ashes, Catch, Bowled, Stump out, Run out, L. B. W; Hit Wicket, Not out, No ball, Wide ball, Dead ball, Over Throw, Bye, Leg by, Cover drive, Late cut, Hook, Glance, Stroke, Shot, Pull, Sixer, Followthrough, Turn, Googley, Spin, Yorker, Bouncer, Hattrick, Round the wicket, Over the wicket, Seamer, Boundry line, Slip, Square leg, Runner, Cover, Gully, Long on, Silly point, Midwicket, Mid on, Forward short leg, Deep/mid-wicket, etc.

● HorseridingThree day Event, Show jumping, Dresses, Faults, etc.

● FootballGoal, Kick, Head, Penalty kick, Dribble, Off side, Hattrick, Foul, Left out, Right out, Stopper, Defender, Move, Sideback, Pass, Baseline, Rebound, Comer bick, etc.

● GymnasticsParellel bar, Horizontal bar, Floor exercise, Uneven bar, Push up, Sit up. etc.

● JudoCocoa, Blue, white, Green belt, etc.

 HockeyBully Sudden death, Short corner, Hattrick, Goal, Penalty Corner, Penalty stroke, Pushin, Cut, Dribble, Scoop, Centre forward, Half back, Astroturf, Left in, Left out, Off-side, Tie breaker, Carried, Stick, Striking circle, Under cutting, etc.

 SwimmingFreestyle, Breast stroke, Back stroke, Butterfly, Lane, Pool, Crawl, etc.

 PoloPolo-Bunker, Chukker, Mallet, etc.

● TennisService, Grandslam, Advantage, Deuce, Game Point, Break point, Smash, Shot, Grass Court, Break, Drop shot, Netplay, Baseline, etc.

● ShootingRapidfire Pistol, Standard rifle, Air rifle, Free pistol, Range, Bull’s eye, etc.

● Table TennisVolley, Late service, Half volley, Back hand, Drive spin, Chop, etc.

● Weight LiftingSnatch, Jerk, etc.

● VolleyballDeuce, Spikers, Booster, Smash, Sidearm, Panetration, etc.

● WrestlingFree style, Hal Nelson, Point, Heave, etc.

DS Interview Questions-4


1.The Quick Sort
The quick sort algorithm is of the divide and conquer type. That means it works by reducing a sorting problem into several easier sorting problems and solving each of them. A dividing value is chosen from the input data, and the data is partitioned into three sets: elements that belong before the dividing value, the value itself, and elements that come after the dividing value. The partitioning is performed by exchanging elements that are in the first set but belong in the third with elements that are in the third set but belong in the first Elements that are equal to the dividing element can be put in any of the three sets the algorithm will still work properly.

2.The Merge Sort
The merge sort is a divide and conquer sort as well. It works by considering the data to be sorted as a sequence of already-sorted lists (in the worst case, each list is one element long). Adjacent sorted lists are merged into larger sorted lists until there is a single sorted list containing all the elements. The merge sort is good at sorting lists and other data structures that are not in arrays, and it can be used to sort things that don't fit into memory. It also can be implemented as a stable sort.

3.The Radix Sort
The radix sort takes a list of integers and puts each element on a smaller list, depending on the value of its least significant byte. Then the small lists are concatenated, and the process is repeated for each more significant byte until the list is sorted. The radix sort is simpler to implement on fixed-length data such as ints.

4.How can I search for data in a linked list?
Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list's members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient.

5.Whatis the heap?
The heap is where malloc(), calloc(), and realloc() get memory.
Getting memory from the heap is much slower than getting it from the stack. On the other hand, the heap is much more flexible than the stack. Memory can be allocated at any time and deallocated in any order. Such memory isn't deallocated automatically; you have to call free().
Recursive data structures are almost always implemented with memory from the heap. Strings often come from there too, especially strings that could be very long at runtime. If you can keep data in a local variable (and allocate it from the stack), your code will run faster than if you put the data on the heap. Sometimes you can use a better algorithm if you use the heap faster, or more robust, or more flexible. Its a tradeoff.
If memory is allocated from the heap, its available until the program ends. That's great if you remember to deallocate it when you're done. If you forget, it's a problem. A memory leak is some allocated memory that's no longer needed but isn't deallocated. If you have a memory leak inside a loop, you can use up all the memory on the heap and not be able to get any more. (When that happens, the allocation functions return a null pointer.) In some environments, if a program doesn't deallocate everything it allocated, memory stays
unavailable even after the program ends.

6.What is the easiest sorting method to use?
The answer is the standard library function qsort(). It's the easiest sort by far for several reasons:
It is already written.
It is already debugged.
It has been optimized as much as possible (usually).
Void qsort(void *buf, size_t num, size_t size, int (*comp)(const void *ele1, const void *ele2));

7. What is an algorithm?
The process of providing solution to a problem is a sequence of steps is called an algorithm.

8. What are the properties of an algorithm?
An algorithm must possess the following properties:
a. It should get input data.
b. It should produce output.
c. The algorithm should terminate.
d. Algorithm should be clear to understand.
e. It should be easy to perform.

9. What are the types of algorithms?
Algorithms are of two types: repetitive and recursive algorithms.

10. Define iterative algorithms.
Algorithms which use loops and conditions to solve the problem are called iterative algorithms.

Tell me about yourself ?

Start with the present and tell why you are well qualified for the position. Remember that the key to all successful interviewing is to match your qualifications to what the interviewer is looking for. In other words you must sell what the buyer is buying. This is the single most important strategy in job hunting.
So, before you answer this or any question it's imperative that you try to uncover your interviewer's greatest need, want, problem or goal.
To do so, make you take these two steps: 

Do all the homework you can before the interview to uncover this person's wants and needs (not the generalized needs of the industry or company)

As early as you can in the interview, ask for a more complete description of what the position entails. You might say: “I have a number of accomplishments I'd like to tell you about, but I want to make the best use of our time together and talk directly to your needs. To help me do, that, could you tell me more about the most important priorities of this position? All I know is what I (heard from the recruiter, read in the classified ad, etc.)”

Then, ALWAYS follow-up with a second and possibly, third question, to draw out his needs even more. Surprisingly, it's usually this second or third question that unearths what the interviewer is most looking for.

You might ask simply, "And in addition to that?..." or, "Is there anything else you see as essential to success in this position?:

This process will not feel easy or natural at first, because it is easier simply to answer questions, but only if you uncover the employer's wants and needs will your answers make the most sense. Practice asking these key questions before giving your answers, the process will feel more natural and you will be light years ahead of the other job candidates you're competing with.

After uncovering what the employer is looking for, describe why the needs of this job bear striking parallels to tasks you've succeeded at before. Be sure to illustrate with specific examples of your responsibilities and especially your achievements, all of which are geared to present yourself as a perfect match for the needs he has just described.

OS Interview Questions-5


1.What is critical section problem?
Ans: Critical section is the code segment of a process in which the process may be changing common variables, updating tables, writing a file and so on. Only one process is allowed to go into critical section at any given time (mutually exclusive).The critical section problem is to design a protocol that the processes can use to co-operate. The three basic requirements of critical section are:
1. Mutual exclusion
2. Progress
3. bounded waiting
Bakery algorithm is one of the solutions to CS problem.

2.What is a semaphore?
Ans: It is a synchronization tool used to solve complex critical section problems. A semaphore is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: Wait and Signal.

3.What is bounded-buffer problem?
Ans: Here we assume that a pool consists of n buffers, each capable of holding one item. The semaphore provides mutual exclusion for accesses to the buffer pool and is initialized to the value 1.The empty and full semaphores count the number of empty and full buffers, respectively. Empty is initialized to n, and full is initialized to 0.

4.What is readers-writers problem?
Ans: Here we divide the processes into two types:
1. Readers (Who want to retrieve the data only)
2. Writers (Who want to retrieve as well as manipulate)
We can provide permission to a number of readers to read same data at same time.But a writer must be exclusively allowed to access. There are two solutions to this problem:
1. No reader will be kept waiting unless a writer has already obtained permission to use the shared object. In other words, no reader should wait for other readers to complete simply because a writer is waiting.
2. Once a writer is ready, that writer performs its write as soon as possible. In other words, if a writer is waiting to access the object, no new may start reading.

5.What is dining philosophers’ problem?
Ans: Consider 5 philosophers who spend their lives thinking and eating. The philosophers share a common circular table surrounded by 5 chairs, each belonging to one philosopher. In the center of the table is a bowl of rice, and the table is laid with five single chop sticks. When a philosopher thinks, she doesn’t interact with her colleagues.
From time to time, a philosopher gets hungry and tries to pick up two chop sticks that are closest to her .A philosopher may pick up only one chop stick at a time. Obviously she can’t pick the stick in some others hand. When a hungry philosopher has both her chopsticks at the same time, she eats without releasing her chopsticks. When she is finished eating, she puts down both of her chopsticks and start thinking again.

6.What is a deadlock?
Ans: Suppose a process request resources; if the resources are not available at that time the process enters into a wait state. A waiting process may never again change state, because the resources they have requested are held by some other waiting processes. This situation is called deadlock.

7.What are necessary conditions for dead lock?
Ans:
1. Mutual exclusion (where at least one resource is non-sharable)
2. Hold and wait (where a process hold one resource and waits for other resource)
3. No preemption (where the resources can’t be preempted)
4. circular wait (where p[i] is waiting for p[j] to release a resource. i= 1,2,…n
j=if (i!=n) then i+1 else 1 )

8.What is resource allocation graph?
Ans: This is the graphical description of deadlocks. This graph consists of a set of edges E and a set of vertices V. The set of vertices V is partitioned into two different types of nodes P={p1,p2,…,pn}, the set consisting of all the resources in the system, R={r1,r2,…rn}.
A directed edge Pi?Rj is called a request edge; a directed edge Rj?Pi is called an assignment edge. Pictorially we represent a process Pi as a circle, and each resource type Rj as square.Since resource type Rj may have more than one instance, we represent each such instance as a dot within the square.When a request is fulfilled the request edge is transformed into an assignment edge. When a process releases a resource the assignment edge is deleted. If the cycle involves a set of resource types, each of which has only a single instance, then a deadlock has occurred. Each process involved in the cycle is deadlock.

9.What are deadlock prevention techniques?
Ans:
1. Mutual exclusion : Some resources such as read only files shouldn’t be mutually exclusive. They should be sharable. But some resources such as printers must be mutually exclusive.
2. Hold and wait : To avoid this condition we have to ensure that if a process is requesting for a resource it should not hold any resources.
3. No preemption : If a process is holding some resources and requests another resource that cannot be immediately allocated to it (that is the process must wait), then all the resources currently being held are preempted(released autonomously).
4. Circular wait : the way to ensure that this condition never holds is to impose a total ordering of all the resource types, and to require that each process requests resources in an increasing order of enumeration.

10.What is a safe state and a safe sequence?
Ans: A system is in safe state only if there exists a safe sequence. A sequence of processes is a safe sequence for the current allocation state if, for each Pi, the resources that the Pi can still request can be satisfied by the currently available resources plus the resources held by all the Pj, with j

C Interview Questions-7


71. What are the two forms of #include directive?
Ans:
1.#include”filename”
2.#include
the first form is used to search the directory that contains the source file.If the search fails in the home directory it searches the implementation defined locations.In the second form ,the preprocessor searches the file only in the implementation defined locations.

72. How would you use the functions randomize() and random()?
Ans:
Randomize( ) initiates random number generation with a random value.
Random( ) generates random number between 0 and n-1;

73. What do the functions atoi(), itoa() and gcvt() do?
Ans:
atoi( ) is a macro that converts integer to character.
itoa( ) It converts an integer to string
gcvt( ) It converts a floating point number to string

74. How would you use the functions fseek(), freed(), fwrite() and ftell()?
Ans:
fseek(f,1,i) Move the pointer for file f a distance 1 byte from location i.
fread(s,i1,i2,f) Enter i2 dataitems,each of size i1 bytes,from file f to string s.
fwrite(s,i1,i2,f) send i2 data items,each of size i1 bytes from string s to file f.
ftell(f) Return the current pointer position within file f.
The data type returned for functions fread,fseek and fwrite is int and ftell is long int.

75. What is the difference between the functions memmove() and memcpy()?
Ans: The arguments of memmove( ) can overlap in memory. The arguments of memcpy( ) cannot.

76. What is a file?
Ans: A file is a region of storage in hard disks or in auxiliary storage devices.It contains bytes of information .It is not a data type.

77. What are the types of file?
Ans: Files are of two types
1-high level files (stream oriented files) :These files are accessed using library functions
2-low level files(system oriented files) :These files are accessed using system calls

78. What is a stream?
Ans: A stream is a source of data or destination of data that may be associated with a disk or other
I/O device. The source stream provides data to a program and it is known as input stream. The destination stream eceives the output from the program and is known as output stream.

79. What is meant by file opening?
Ans: The action of connecting a program to a file is called opening of a file. This requires creating
an I/O stream before reading or writing the data.

80. What is FILE?
Ans: FILE is a predefined data type. It is defined in stdio.h file.

CN Interview Questions-8


1.What do you mean by data communication?
Ans: It is the exchange of data between two devices via some form of transmission medium such as wire cable. The communicating system must be part of a communication system made up of a combination of hardware and software.The effectiveness of a data communication system depends on three fundamental characteristics: delivery, accuracy and timeliness.

2.What is simplex?
Ans: It is the mode of communication between two devices in which flow of data is unidirectional. i.e. one can transmit and other can receive.
E.g. keyboard and monitor.

3.What is half-duplex?
Ans: It is the mode of communication between two devices in which flow of data is bi-directional but not at the same time. ie each station can transmit and receive but not at the same time.
E.g walkie-talkies are half-duplex system.

4.What is full duplex?
Ans: It is the mode of communication between two devices in which flow of data is bi-directional and it occurs simultaneously. Here signals going in either direction share the capacity of the link.
E.g. telephone

5.What is a network?
Ans: It is a set of devices connected by communication links. A node can be a computer or any other device capable of sending and/or receiving data generated by other nodes on the network.
6.What is distributed processing?
Ans: It is a strategy in which services provided by the network reside at multiple sites.

7.What is point to point connection?
Ans:It provides a dedicated link between two devices. The entire capacity of the link is reserved for transmission between the two devices
e.g. when we change the TV channels by remote control we establish a point to point connection between remote control and TV control system.

8.What is multipoint connection?
Ans: In multipoint connection more than two specific devices share a single link.
Here the capacity of the channel is shared either separately or temporally.

9.What is a topology?
Ans: Topology of a network is defined as the geometric representation of the relationship of all the links and linking devices (node) to one another.Four basic topologies are star, bus, ring and mesh.
Star – Here each device has a dedicated point to point link only to a central controller called hub.
Bus -It is multipoint. One long cable acts as a backbone to link all the devices in the network.
Ring -Here each device has a dedicated point to point connection only with the two devices on either side of it.
Mesh -Here every device has a dedicated point to point link to every other device.

UNIX Interview Questions-6


51. What is the working set of a process?
Ans: The set of pages that are referred by the process in the last ‘n’, references, where ‘n’ is called the window of the working set of the process.

52. What is the window of the working set of a process?
Ans: The window of the working set of a process is the total number in which the process had referred the set of pages in the working set of the process.

53. What is called a page fault?
Ans: Page fault is referred to the situation when the process addresses a page in the working set of the process but the process fails to locate the page in the working set. And on a page fault the kernel updates the working set by reading the page from the secondary device.

54. What are data structures that are used for Demand Paging?
Ans: Kernel contains 4 data structures for Demand paging. They are, Page table entries, Disk block descriptors, Page frame data table (pfdata), Swap-use table.

55. What are the bits that support the demand paging?
Ans: Valid, Reference, Modify, Copy on write, Age. These bits are the part of the page table entry, which includes physical address of the page and protection bits.
- Page address
- Age
- Copy on write
- Modify
- Reference
- Valid
- Protection

56. How the Kernel handles the fork() system call in traditional Unix and in the System V Unix, while swapping?
Ans: Kernel in traditional Unix, makes the duplicate copy of the parent’s address space and attaches it to the child’s process, while swapping. Kernel in System V Unix, manipulates the region tables, page table, and pfdata table entries, by incrementing the reference count of the region table of shared regions.

57. Difference between the fork() and vfork() system call?
Ans: During the fork() system call the Kernel makes a copy of the parent process’s address space and attaches it to the child process. But the vfork() system call do not makes any copy of the parent’s address space, so it is faster than the fork() system call. The child process as a result of the vfork() system call executes exec() system call. The child process from vfork() system call executes in the parent’s address space (this can overwrite the parent’s data and stack ) which suspends the parent process until the child process exits.

58. What is BSS(Block Started by Symbol)?
Ans: A data representation at the machine level, that has initial values when a program starts and tells about how much space the kernel allocates for the un-initialized data. Kernel initializes it to zero at run-time.

59. What is Page-Stealer process?
Ans: This is the Kernel process that makes rooms for the incoming pages, by swapping the memory pages that are not the part of the working set of a process. Page-Stealer is created by the Kernel at the system initialization and invokes it throughout the lifetime of the system. Kernel locks a region when a process faults on a page in the region, so that page stealer cannot steal the page, which is being faulted in.

60. Name two paging states for a page in memory?
Ans: The two paging states are:
The page is aging and is not yet eligible for swapping,
The page is eligible for swapping but not yet eligible for reassignment to other virtual address space.

Monday, 24 September 2012

UNIX Interview Questions-5


41. What is Expansion swap?
Ans: At the time when any process requires more memory than it is currently allocated, the Kernel performs Expansion swap. To do this Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later when the Kernel swaps the process into the main memory this assigns memory according to the new address translation mapping.

42. How the Swapper works?
Ans: The swapper is the only process that swaps the processes. The Swapper operates only in the Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process.

43. What are the processes that are not bothered by the swapper? Give Reason.
Ans: Zombie process: They do not take any up physical memory.Processes locked in memories that are updating the region of the process.Kernel swaps only the sleeping processes rather than the ‘ready-to-run’ processes, as they have the higher probability of being scheduled than the Sleeping processes.

44. What are the requirements for a swapper to work?
Ans: The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if not found then it will look for the ready-to-run process for swapping. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds before swapping out. And for swapping in the process must have been resided in the swap device for at least 2 seconds. If the requirement is not satisfied then the swapper will go into the wait state on that event and it is awaken once in a second by the Kernel.

45. What are the criteria for choosing a process for swapping into memory from the swap device?
Ans: The resident time of the processes in the swap device, the priority of the processes and the amount of time the processes had been swapped out.

46. What are the criteria for choosing a process for swapping out of the memory to the swap device?
Ans: The process’s memory resident time,Priority of the process and the nice value.

47. What do you mean by nice value?
Ans: Nice value is the value that controls {increments or decrements} the priority of the process. This value that is returned by the nice () system call. 
The equation for using nice value is:
 Priority = (“recent CPU usage”/constant) + (base- priority) + (nice value) 
Only the administrator can supply the nice value. The nice () system call works for the running process only. Nice value of one process cannot affect the nice value of the other process.

48. What are conditions on which deadlock can occur while swapping the processes?
Ans: All processes in the main memory are asleep.All ‘ready-to-run’ processes are swapped out. There is no space in the swap device for the new incoming process that are swapped out of the main memory. There is no space in the main memory for the new incoming process.

49. What are conditions for a machine to support Demand Paging?
Ans: Memory architecture must based on Pages, The machine must support the ‘restartable’ instructions.

50. What is ‘the principle of locality’?
Ans: It’s the nature of the processes that they refer only to the small subset of the total data space of the process. i.e. the process frequently calls the same subroutines or executes the loop instructions.