Race Condition Is An Undesirable Situation That Occurs When A Device or System Attempts To
Race Condition Is An Undesirable Situation That Occurs When A Device or System Attempts To
Race Condition Is An Undesirable Situation That Occurs When A Device or System Attempts To
How are the wait/signal operations for monitor different from those for semaphores?
If a process in a monitor signal and no task is waiting on the condition variable, the signal is
lost. So this allows easier program design. Whereas in semaphores, every operation affects
the value of the semaphore, so the wait and signal operations should be perfectly balanced in
the program.
race condition is an undesirable situation that occurs when a device or system attempts to
perform two or more operations at the same time, but because of the nature of the device or
system, the operations must be done in the proper sequence to be done correctly.
What is spinloack ?
What is SMP?
To achieve maximum efficiency and reliability a mode of operation known as symmetric
multiprocessing is used. In essence, with SMP any process or threads can be assigned to any
processor.
Dynamic scheduling: The number of thread in a program can be altered during the course of
execution.
If a thread which had already locked a mutex, tries to lock the mutex again, it will enter into the
waiting list of that mutex, which results in deadlock. It is because no other thread can unlock the
mutex
If you want to execute C program even after main function is terminated, which
function can be used?
“atexit()” function can be used if we want to execute any function after program is
terminated normally.
Syntax: int atexit (void (*func)(void));
The function “func” will be called automatically without any arguments once program
is terminated normally.
16. What is the difference between structured oriented, object oriented and non-
structure oriented programming language?
In this type of language, large programs are divided into small programs called
functions.
Prime focus is on functions and procedures that operate on data
Data moves freely around the systems from one function to another
Program structure follows “Top Down Approach”
Example: C, Pascal, ALGOL and Modula-2
To override an existing macro, we need to undefine existing macro using “#undef”. Then, we
need to define same macro again with new value
What is the difference between strcpy() & strncpy() functions in C?
strcpy( ) function copies whole content of one string into another string. Whereas,
strncpy( ) function copies portion of contents of one string into another string.
If destination string length is less than source string, entire/specified source string
value won’t be copied into destination string in both cases.
No. Array subscripts should not have negative value. Always, it should be positive.
Uninitialized pointers are called as wild pointers in C which points to arbitrary (random)
memory location. This wild pointer may lead a program to behave wrongly or to crash.
Is pointer arithmetic a valid one? Which arithmetic operation is not valid in pointer?
Why?
Pointer arithmetic is not valid one. Pointer addition, multiplication and division are not
allowed as these are not making any sense in pointer arithmetic.
But, two pointers can be subtracted to know how many elements are available between these
two pointers
NULL pointer is pointer that is pointing to nothing (No memory location). Accessing null
pointer in C may lead a program to crash. So, Null pointer should not be accessed in a
program.
void f()
{
int *ptr = (int *) malloc(sizeof(int));
/* Do some work */
Can a pointer be freed more than once in C? What happens if do so? Or can a pointer
be freed twice in C?
1st scenario: After freeing a pointer in a C program, freed memory might be reallocated by
some other or same program luckily. In this scenario, freeing the same pointer twice won’t
cause any issue.
2nd scenario: We can free a pointer. Then, we can allocate memory for same pointer variable.
Then, we can use it and free it again. This is also not an issue.
3rd scenario: If we free the same pointer second time without reallocating memory to that
pointer, then what happens? As per ANSI/ISO C standard, this is undefined behaviour. This
undefined behaviour may cause anything to the program that we do not expect to happen.
.What does abstract Data Type Mean
In computer science, an abstract data type (ADT) is a mathematical model for data types where a
data type is defined by its behavior (semantics) from the point of view of a user of the data,
specifically in terms of possible values, possible operations on data of this type, and the behavior of
these operations.
It depends on how connected the graph is. A complete undirected graph can have maximum
nn-1 number of spanning trees, where n is number of nodes.
What is hashing?
Hashing is a technique to convert a range of key values into a range of indexes of an array.
By using hash tables, we can create an associative data storage where data index can be find
by providing its key values.
It actually depends on where you intend to apply linked lists. If you based it on storage, a
linked list is considered non-linear. On the other hand, if you based it on access strategies,
then a linked list is considered linear
An ordered list is a list in which each node’s position in the list is determined by the value of
its key component, so that the key values form an increasing sequence, as the list is traversed.
In RDBMS, what is the efficient data structure used in the internal storage representation?
B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This
corresponds to the records that shall be stored in leaf nodes.
Does the Minimal Spanning tree of a graph give the shortest distance
between any 2 specified nodes?
- No, it doesn’t.
- It assures that the total weight of the tree is kept to minimum.
- It doesn't imply that the distance between any two nodes involved in the minimum-spanning tree
is minimum.
If you are using C language to implement the heterogeneous linked list,
what pointer type will you use?
- A heterogeneous linked list contains different data types in its nodes. We can not use ordinary
pointer to connect them.
- The pointer that we use in such a case is void pointer as it is a generic pointer type and capable of
storing pointer to any type.
Non-Linear data structure: Every data item is attached to several other data items in a way that is
specific for reflecting relationships. The data items are not arranged in a sequential structure. Ex:
Trees, Graphs
Explain the sorting algorithm that is most suitable to be used with single
linked list?
The sorting algorithm that is most suitable with the single link list is the simple insertion sort. This
consists of an array and link of pointers, where the pointers are pointing to each of the element in
the array. For example: l[i] = i + 1 for 0 < = i < n-1 and l[n-1] = -1.
The linear link list can be pointed by the external pointer which initialized it to 0. To insert the nth
element in the list the traversing time gets reduced and until the list is being sorted out completely
the process doesn't end. The array that has to be traversed x[k] to sort the element and put them in
the list. If the sorting is done then it reduces the time of the insertion of an element and time for
searching for a particular element at proper position.
Max-heap contains the root element as the highest element in the heap and from there the
descending elements will be shown on the children node. It will also be traversed in an orderly
manner and will be accessed by accessing the root first then their children nodes
What is Multiplexing?
Multiplexing is the set of techniques that allows the simultaneous transmission of multiple
signals across a single data link.
What is ICMP?
ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite
used by hosts and gateways to send notification of datagram problems back to the sender. It
uses the echo test / reply to test whether a destination is reachable and responding. It also
handles both control and error messages.
4.1 Repeaters:
As signals travel along a network cable (or any other medium of transmission), they degrade
and become distorted in a process that is called attenuation. If a cable is long enough, the
attenuation will finally make a signal unrecognizable by the receiver.
A Repeater enables signals to travel longer distances over a network. Repeaters work at the
OSI's Physical layer. A repeater regenerates the received signals and then retransmits the
regenerated (or conditioned) signals on other segments.
To pass data through the repeater in a usable fashion from one segment to the next, the
packets and the Logical Link Control (LLC) protocols must be the same on the each segment.
This means that a repeater will not enable communication, for example, between an 802.3
segment (Ethernet) and an 802.5 segment (Token Ring). That is, they cannot translate an
Ethernet packet into a Token Ring packet. In other words, repeaters do not translate anything.
4.2 Bridges:
Like a repeater, a bridge can join segments or workgroup LANs. However, a bridge can also
divide a network to isolate traffic or problems. For example, if the volume of traffic from one
or two computers or a single department is flooding the network with data and slowing down
entire operation, a bridge can isolate those computers or that department.
In the following figure, a bridge is used to connect two segment segment 1 and segment 2.
Bridges can be used to:
Bridges work at the Data Link Layer of the OSI model. Because they work at this layer, all
information contained in the higher levels of the OSI model is unavailable to them.
Therefore, they do not distinguish between one protocol and another.
Bridges simply pass all protocols along the network. Because all protocols pass across the
bridges, it is up to the individual computers to determine which protocols they can recognize.
A bridge works on the principle that each network node has its own address. A bridge
forwards the packets based on the address of the particular destination node.
As traffic passes through the bridge, information about the computer addresses is then stored
in the bridge's RAM. The bridge will then use this RAM to build a routing table based on
source addresses.
4.3 Routers:
Routers work at the Network layer of the OSI model meaning that the Routers can switc h
and route packets across multiple networks. They do this by exchanging protocol-specific
information between separate networks.Routers have access to more information in packets
than bridges, and use this information to improve packet deliveries. Routers are usually used
in a complex network situation because they provide better traffic management than bridges
and do not pass broadcast traffic.
Routers can share status and routing information with one another and use this information to
bypass slow or malfunctioning connections.
Routers do not look at the destination node address; they only look at the network address.
Routers will only pass the information if the network address is known. This ability to control
the data passing through the router reduces the amount of traffic between networks and
allows routers to use these links more efficiently than bridge
4.4 Gateways:
Communication protocols
Data formatting structures
Languages
Architecture
For example, electronic mail gateways, such as X.400 gateway, receive messages in one
format, and then translate it, and forward in X.400 format used by the receiver, and vice
versa.
Decapsulates incoming data through the networks complete protocol stack. Encapsulates the
outgoing data in the complete protocol stack of the other network to allow transmission.
4.5 NIC
A NIC or Network Interface Card is a circuit board or chip, which allows the computer to
communicate to other computers on a Network. This board when connected to a cable or
other method of transferring data such as infrared can share resources, information and
computer hardware. Local or Wide area networks are generally used for large businesses as
well as are beginning to be found in homes as home users begin to have more then one
computer. Utilizing network cards to connect to a network allow users to share data such as
companies being able to have the capability of having a database that can be accessed all at
the same time send and receive e-mail internally within the company or share hardware
devices such as printers.
4.6 Connectors:
Network cards have three main types of connectors. Below is an example of what a network
card may look like.
4.6.1 BNC connector:As illustrated in the above picture the BNC connector is a round connector,
which is used for thin net or 10Base-2 Local Area Network.
4.6.2 DB9 (RJ45 JACK): The DB9 connector not to be confused with the Serial Port or sometimes
referred to as the RJ45 JACK not to be confused with the RJ45 connection is used with Token Ring
networks.
4.6.3 DB15 Connector: The DB15 connector is used for a Thick net or 10Base-5 Local area network.
4.6.4 RJ45 connector: Today one of the most popular types of connections used with computer
networks. RJ45 looks similar to a phone connector or RJ11 connector however is slightly larger.
LED - The LED's as shown in the above illustration indicates if it detects a network generally by a
green light which may flash as it communicates and then a red light which indicates collisions which
will generally flash or not flash at all.
4.7 Cables
What is difference between ARP and RARP?
The address resolution protocol (ARP) is used to associate the 32 bit IP address with the 48
bit physical address, used by a host or a router to find the physical address of another host on
its network by sending a ARP query packet that includes the IP address of the receiver.
The reverse address resolution protocol (RARP) allows a host to discover its Internet address
when it knows only its physical address.
What is the difference between TFTP and FTP application layer protocols?
The Trivial File Transfer Protocol (TFTP) allows a local host to obtain files from a remote
host but does not provide reliability or security. It uses the fundamental packet delivery
services offered by UDP.
The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for
copying a file from one host to another. It uses the services offer by TCP and so is reliable
and secure. It establishes two connections (virtual circuits) between the hosts, one for data
transfer and another for control information
4. What is kernel?
Kernel is the core and essential part of computer operating system that provides basic services for all parts of
OS.
Micro kernel is a kernel which run services those are minimal for operating system performance. In this kernel all
other operations are performed by processor.
Macro Kernel is a combination of micro and monolithic kernel. In monolithic kernel all operating system code is in
single executable image.
Starvation is Resource management problem where a process does not get the resources it needs for a long
time because the resources are being allocated to other processes.
When many of free blocks are too small to satisfy any request then fragmentation occurs. External fragmentation
and internal fragmentation are two types of fragmentation. External Fragmentation happens when a dynamic
memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively
used. Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the
allowed sizes of allocated blocks.
Hardware device that maps virtual to physical address. In MMU scheme, the value in the relocation register is
added to every address generated by a user process at the time it is sent to memory.
->The user program deals with logical addresses; it never sees the real physical addresses
Trapdoor is a secret undocumented entry point into a program used to grant access without normal methods of
access authentication. A trap is a software interrupt, usually the result of an error condition.
The set of dispatchable processes is in a safe state if there exists at least one temporal order in which all
processes can be run to completion without resulting in a deadlock.
. What is Marshalling?
The process of packaging and sending interface method parameters across thread or process boundaries.
47. What is DRAM?
Dynamic Ram stores the data in the form of Capacitance, and Static RAM stores the data in Voltages.
DRAM requires the data to be refreshed periodically in order to retain the data. SRAM does
not need to be refreshed as the transistors inside would continue to hold the data as long as
the power supply is not cut off. This behavior leads to a few advantages, not the least of
which is the much faster speed that data can be written and read
Local replacement means that an incoming page is brought in only to the relevant process' address space.
Global replacement policy allows any page frame from any process to be replaced. The latter is applicable to
variable partitions model only.
In message passing, it is the condition in which, both, the sender and receiver are blocked until the message is
delivered.
Livelock, which means that the code is still actively running, but you have reached a state
that you cannot leave. For example:
What resources are used when a thread created? How do they differ from those when a process
is created?
Ans. When a thread is created the threads does not require any new resources to execute the
thread shares the resources like memory of the process to which they belong to. The benefit
of code sharing is that it allows an application to have several different threads of activity all
within the same address space. Whereas if a new process creation is very heavyweight
because it always requires new address space to be created and even if they share the memory
then the inter process communication is expensive when compared to the communication
between the threads.
What is the cause of thrashing? How does the system detect thrashing?
Ans. Once it detects thrashing, what can the system do to eliminate this problem? - Thrashing is
caused by under allocation of the minimum number of pages required by a process, forcing it to
continuously page fault. The system can detect thrashing by evaluating the level of CPU utilization as
compared to the level of multiprogramming. It can be eliminated by reducing the level of
multiprogramming.