Friday, October 28, 2016

                                            Polymorphism

In object-oriented programming, Polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. In other words, It is the ability to redefine methods for derived classes. Polymorphism is considered to be a requirement of any true Object-Oriented Programming Language (OOPL). There can we several types of Polymorphism.

What are the different types of Polymorphism ?

  • Ad hoc polymorphism: When the function denotes different heterogeneous implementations depending on a limited range of individually specified types and combinations. Ad hoc polymorphism is supported in many languages using function overloading.
  • Parametric polymorphism: When code is written without mention of any specific time and thus can be used transparently with any number of new types. In object-oriented programming community, this is often known as generics or generic programming. In functional programming community, this is often simply referred to as polymorphism.
  • Sub typing :This is also called subtype polymorphism or inclusion polymorphism. When a name denotes instances of many different classes related by some common superclass. In the object-oriented programming community, this is often simply referred to as polymorphism.
The interaction between parametric polymorphism and sub typing that leads to the concepts of variance  and bounded quantification. 

When is Polymorphism useful ?

The usefulness of Polymorphism depends on the programmer's design and logic. If the programmer  wants to bind your implementation at runtime then Subtype polymorphism will be useful. If you want to invoke different implementation at runtime based on the input arguments then ad-hoc polymorphism will help. If the programmer wants to write a code with a family of types, the code can ignore type specific details and  just interact with the base type of family. Even though the code thinks it is using an object's class could actually be the base class or any one of its subclasses. This makes it easier the programmer to write the code and the readers to understand.Overall, polymorphism provides a powerful feature in binding the  implementation at runtime and provides design extensibility.
_________________________________________________________________________________

References



_________________________________________________________________________________

Friday, October 21, 2016

                               Deadlock   

      Earlier the computer operating system ran only one program at a time. All the resources of the system were available to this one program. As technology developed, operating system ran multiple programs at once, interleaving them.This brought in the problem of Deadlock. Deadlock is a situation in which two computer programs share the same resources and effectively prevent each other from accessing the resources which results in both programs ceasing to function. In other words, this is a condition that occurs when two processes are each waiting for the each other to complete before proceeding and thus, the result is that both processes hang. Deadlocks mostly occur in multitasking and client/server environments.

What are the necessary conditions ?

There are four necessary conditions to achieve deadlocks :-

1) Mutual Exclusion: At least one resource must be held in a non-shareable mode; If any other process requests this resource, then the process must wait for the resource to be released.

2) Hold and Wait :A process must be simultaneously holding at least one resource and waiting for at least one resource that is currently being held by some other process.

3) No preemption: Once a process is holding a resource, then that resource cannot be taken away from that process until the process voluntarily releases it.
4)Circular Wait : A set of processes {P0,P1,P2, ....PN } must exist such that every P[i] is waiting       for P[(i+1)%(N+1)].



How to handle a deadlock ?


1)Generally speaking there are three ways of handling deadlocks:
  • Deadlock prevention or avoidance - Do not allow the system to get into a deadlocked state.
  • Deadlock detection and recovery - Abort a process or preempt some resources when deadlocks are detected.
  • Ignore the problem all together - If deadlocks only occur once a year or so, it may be better to simply let them happen and reboot as necessary than to incur the constant overhead and system performance penalties associated with deadlock prevention or detection. 

2) In order to avoid deadlocks, the system must have additional information about all processes. In particular, the system must know what resources a process will or may request in the future.

3)Deadlock detection is fairly straightforward, but deadlock recovery requires either aborting processes or preempting resources, neither of which is an attractive alternative.

4)If deadlocks are neither prevented nor detected, then when a deadlock occurs the system will gradually slow down, as more and more processes become stuck waiting for resources currently held by the deadlock and by other waiting processes. Unfortunately this slowdown can be indistinguishable from a general system slowdown when a real-time process has heavy computing needs.
_________________________________________________________________________________

Reference

_________________________________________________________________________________

Friday, October 14, 2016

                       Chrome  Extensions
        An extension is a zipped bundle of files- HTML, CSS, JavaScript, images and anything else that is needed and that adds functionality to the Google Chrome browser. Many extensions add UI to the  Google Chrome in the form of browser actions or page actions.Each extension can have at most one browser action or page action. A browser action that is most relevant to most pages is chosen. A page action is chosen according to when the extension icon should be active or inactive, depending on the page. Extensions are essentially web pages that can use all the APIs that the browser provides to web page. 
Each of the extensions have the following files 

  • A manifest file
  • One or more HTML files (unless the extension is a theme)
  • Optional: One or more Javascript files
  • Optional: Any other files your extension needs- for example, image files

The manifest file, called manifest.json, gives information about the extension such as the most important files and the capabilities that the extension might use.
     The most popular Google Chrome Extensions are Honey, Hangouts, Momentum, Office Online, Grammarly, Google Keep and Stay Focused. Each of them improvise the functions provided to us by  Chrome. 
The Extension Honey helps people find the best deal on any of the online shopping sites. The extension Hangout helps people to keep in touch and communicate.The Extension Google Keep helps people to take notes. The extension Grammarly helps people to get rid of all the typing errors they make while writing an articles. This extensions also fixes all the Grammatical errors and provides better vocabulary and phrasing for the sentences. The extension Stay Focused helps people to avoid getting distracted while researching. Google chrome was extremely powerful in itself but with these extensions added to it, it has become unbeatable.
_________________________________________________________________________________


Reference


_________________________________________________________________________________








Friday, October 7, 2016

                                      Operating System 

The operating system is the most important program that runs on a computer. It is the software that supports a computer's basic functions such as scheduling tasks, executing applications, and controlling peripherals. Every general purpose computer must have an operating system to run other programs and applications. For large  systems, the operating system has even greater responsibilities and powers. It makes sure that different programs and users running at the same time do not interfere with each other.


 What is the classification of Operating Systems?

 TheOperating System can be of different types :
  • Multi-user: It allows two or more users to run programs at the same time. Some operating systems permit hundreds or even thousands of concurrent users.
  • Multi-tasking : It supports running a program on more than one CPU.
  • Multi-processing: It allows more than one program to run concurrently.
  • Multi-threading: It allows different parts of a single program to run concurrently.
  • Real Time: It responds to input instantly.The general-purpose operating systems are not real time. 

What are the functions of operating systems ?

  • Memory Management: Memory management refers to the management of Primary Memory or Main Memory. Main Memory is a large array of words or bytes where each word or byte has its own address.The operating system does the following activities:
            - Keeps track of primary memory
            - In Multiprogramming, the OS decides which process will get me memory and how much
            - allocates the memory when a process requests it to do so.
            - De-allocates the memory when a process no longer needs it or has been terminated.
  • Processor Management:In multiprogramming environment, the OS decides which process gets the processor when and for how much time. This function is called Process Scheduling. An Operating System does the following activities for Processor management:   
          -Keeps track of processor and status of the process. The program responsible for this task is                  known as Traffic Controller
          -Allocate a processor(CPU) to a process
          - De-Allocate processor when a process is no longer required
  • Device Management:An operating System manages device communication via their respective drivers. The Operating System does the following Activities for the Device Management -
           - Keeps track of all devices.Program responsible for this task is known as I/O Controller
           - Decides which process gets the device when and for how much time.
           - Allocates the device in the efficient way.
           - De-allocates devices.
  • File Management: A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions.An operating System does the following activities for file management:
           - Keeps track of information, location, uses, status and etc. The collective facilities are often                  known as file system.
           - Decides who gets the resources.
           - Allocates the resources.
           - De-allocate the resources.
  • Others : The other important Activities include:
            - Security
            - Control over system performances
            - Job accounting 
            - Error detecting aids
            - Coordination between other softwares and users.

________________________________________________________________________________

References

________________________________________________________________________________