Posts

Showing posts from December, 2016

Polymorphism

Image
Polymorphism is a feature of OOP that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation. By dint of polymorphism, it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler’s job to select the specific action as it applies to each situation. The programmer does not need to make the selection manually. He needs only remember and utilize the general interface. In this way, polymorphism promotes extensibility.

Features of object-oriented programming over the procedure-oriented and Java as platform independence

Image
Java makes platform independence possible by translating a program into bytecode instead of machine code. Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system or JVM (Java Virtual Machine). Translating a Java program into bytecode makes it much easier to run a program in a wide variety of environments because only the JVM needs to be implemented for each platform. Once the run-time package exists for a given system, any Java program can run on it. Although the details of the JVM will differ from platform to platform, all understand the same Java bytecode. If a Java program were compiled to native code, then different versions of the same program would have to exist for each type of CPU. Thus, the execution of bytecode by the JVM is the easiest way to create truly portable programs.

There are three principles of OOP short definations

Image
Encapsulation Inheritance Polymorphism Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safe from outside interference and misuse.  Inheritance is the process by which one object acquires the properties of another object. By use of inheritance, an object would need only to define those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case. Polymorphism is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation.

DEADLOCKS and METHODS FOR HANDLING DEADLOCKS in OS

Image
In a multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the resources are not available at that time, the process enters a waiting state. Coming to definition Sometimes, a waiting process is never again able to change state, because the resources it has requested are held by other waiting processes. This situation is called a deadlock. The principle of   Deadlock can be defined as the permanent blocking of a set of processes that either competes for system resources or communicate with each other. A situation in which two or more processes are unable to proceed because each is waiting For one of the others to do something. A set of processes is deadlocked (is in a deadlocked state) when each process in the set is blocked waiting for an event that can only be triggered (caused) by another blocked process in the set. All deadlocks involve conflicting needs for resources by two or more processes. This is what

PAGE REPLACEMENT ALGORITHMS in OS

Image
PAGE REPLACEMENT ALGORITHMS In general, we want a page replacement algorithm with the lowest page-fault rate. We evaluate an algorithm by running it on a particular string of memory references and computing the number of page faults on that string. To determine the number of page faults for a particular reference string and page replacement algorithm, we also need to know the number of page frames available. Obviously, as the number of frames available increases, the number of page faults decreases. (Expected relationship between number of free frames allocated to a process and the number of page faults caused by it). FIFO Page Replacement The simplest page-replacement algorithm is a FIFO algorithm.   When a page must be replaced, the oldest page is chosen. We can create a FIFO queue to hold all pages in memory. We replace the page at the head of the queue. When a page is brought into memory we insert t at the tail of the queue.   Example: consider the reference string: 7, 0, 1, 2, 0,
Image
BASIC ELEMENTS OF COMPUTER A computer consists of the processor, memory, and I/O components, with one or more modules of each type. These components are interconnected in some fashion to achieve the main function of the computer, which is to execute programs. Thus, there are four main structural elements: 1.       Processor: Controls the operation of the computer and performs its data processing functions. When there is only one processor, it is often referred to as the central processing unit (CPU). 2.       Main memory: Stores data and programs. This memory is typically volatile; that is when the computer is shutdown, the contents of the memory are lost. In contrast, the contents of disk memory are retained even when the computer system is shut down. Main memory is also referred to as real memory or primary memory. 3.       I/O modules: Move data between the computer and its external environment. The external environment consists of a variety of devices, including secondary memory

Cache memory

Image
Although cache memory is invisible to the OS, it interacts with other memory management hardware. Furthermore, many of the principles used in virtual memory schemes  are also applied in the cache memory. On all instruction cycles, the processor accesses memory at least once, to fetch the instruction, and often one or more additional times, to fetch operands and/ or store results. The rate at which the processor can execute instructions is clearly limited by the memory cycle time (the time it takes to read one word from or write one word to memory). This limitation has been a significant problem because of the persistent mismatch between the processor and main memory speeds: Over the years, processor speed has consistently increased more rapidly than memory access speed. We are faced with a trade-off among speed, cost, and size. Ideally, main memory should be built with the same technology as that of the processor registers, giving memory cycle times comparable to processor cycle times.

THREADS IN OPERATING SYSTEM

Image
A thread is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack. It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals. Threads share the memory and the resources of the process to which they belong by default. Single threaded process A traditional (or heavyweight ) process has a single thread of control. when a process is running a word-processor program, a single thread of instructions is being executed. This single thread of control allows the process to perform only one task at a time. A single-threaded process has one program counter specifying the next instruction to execute. The execution of such a process must be sequential.  The CPU executes one instruction of the process after another until the process completes. multithreaded process If a process has multiple threads of control, it can perform more than one task at a

PROCESS STATE

Image
PROCESS STATE The state of a process is defined in part by the current activity of that process. As a process executes, it changes state . A process may be in one of the following states: 1.       New . The process is being created. 2.       Running . Instructions are being executed. 3.       Waiting . The process is waiting for some event to occur (such as an I/O completion or reception of a signal). 4.       Ready . The process is waiting to be assigned to a processor. 5.       Terminated . The process has finished execution. The states that they represent are found on all systems. It is important to realize that only one process can be running on any processor at any instant. Many processes may be ready and waiting, however. The state diagram corresponding to these states is presented below. Diagram of process states     SCHEDULING QUEUES Job queues As processes enter the system, they are put into a job queue , which consists of all processes in the system. Ready queues ·          T