Tuesday, March 31, 2015

Cursors in SQL Server

0 comments


What are Cursors?



  • A cursor is a temporary work area created in the system memory when a SQL statement is executed. A cursor contains information on a select statement and the rows of data accessed by it. This temporary work area is used to store the data retrieved from the database, and manipulate this data. A cursor can hold more than one row, but can process only one row at a time. The set of rows the cursor holds is called theactive set.


There are two types of cursors in PL/SQL:

Implicit cursors:

  • These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed. They are also created when a SELECT statement that returns just one row is executed. 


Explicit cursors:

  • They must be created when you are executing a SELECT statement that returns more than one row. Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row. When you fetch a row the current row position moves to next row.



Both implicit and explicit cursors have the same functionality, but they differ in the way they are accessed. 

Read full post »

Monday, March 30, 2015

Types of Operating System in Computer Machine

0 comments


Batch processing Operating System



  • Batch processing is a technique in which Operating System collects one programs and data together in a batch before processing starts. Operating system does the following activities related to batch processing.
    • OS defines a job which has predefined sequence of commands, programs and data as a single unit.
    • OS keeps a number a jobs in memory and executes them without any manual information.
    • Jobs are processed in the order of submission i.e first come first served fashion.
    • When job completes its execution, its memory is released and the output for the job gets copied into an output spool for later printing or processing.


Batch processing Operating System



  • Advantages
    • Batch processing takes much of the work of the operator to the computer.
    • Increased performance as a new job get started as soon as the previous job finished without any manual intervention.

  • Disadvantages
    • Difficult to debug program.
    • A job could enter an infinite loop.
    • Due to lack of protection scheme, one batch job can affect pending jobs.

 

Multitasking Operating System


  • Multitasking refers to term where multiple jobs are executed by the CPU simultaneously by switching between them.Switches occur so frequently that the users may interact with each program while it is running. Operating system does the following activities related to multitasking.
    • The user gives instructions to the operating system or to a program directly, and receives an immediate response.
    • Operating System handles multitasking in the way that it can handle multiple operations / executes multiple programs at a time.
    • Multitasking Operating Systems are also known as Time-sharing systems.
    • These Operating Systems were developed to provide interactive use of a computer system at a reasonable cost.
    • A time-shared operating system uses concept of CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared CPU.
    • Each user has at least one separate program in memory. 


Multitasking Operating System


  • A program that is loaded into memory and is executing is commonly referred to as a process.
  • When a process executes, it typically executes for only a very short time before it either finishes or needs to perform I/O.
  • Since interactive I/O typically runs at people speeds, it may take a long time to completed. During this time a CPU can be utilized by another process.
  • Operating system allows the users to share the computer simultaneously. Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user.
  • As the system switches CPU rapidly from one user/program to the next, each user is given the impression that he/she has his/her own CPU, whereas actually one CPU is being shared among many users.



Multiprogramming Operating System


  • When two or more programs are residing in memory at the same time, then sharing the processor is referred to the multiprogramming. Multiprogramming assumes a single shared processor. Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute.


Following figure shows the memory layout for a multiprogramming system.



Multiprogramming Operating System




Operating system does the following activities related to multiprogramming.
  • The operating system keeps several jobs in memory at a time.
  • This set of jobs is a subset of the jobs kept in the job pool.
  • The operating system picks and begins to execute one of the job in the memory.
  • Multiprogramming operating system monitors the state of all active programs and system resources using memory management programs to ensures that the CPU is never idle unless there are no jobs

Advantages
  • High and efficient CPU utilization.
  • User feels that many programs are allotted CPU almost simultaneously.
Disadvantages
  • CPU scheduling is required.
  • To accommodate many jobs in memory, memory management is required.

Interactivity


Interactivity refers that a User is capable to interact with computer system. Operating system does the following activities related to interactivity.
  • OS provides user an interface to interact with system.
  • OS managers input devices to take inputs from the user. For example, keyboard.
  • OS manages output devices to show outputs to the user. For example, Monitor.
  • OS Response time needs to be short since the user submits and waits for the result.

Real Time System Operating System


Real time systems represents are usually dedicated, embedded systems. Operating system does the following activities related to real time system activity.
  • In such systems, Operating Systems typically read from and react to sensor data.
  • The Operating system must guarantee response to events within fixed periods of time to ensure correct performance.

Distributed Environment


Distributed environment refers to multiple independent CPUs or processors in a computer system. Operating system does the following activities related to distributed environment.
  • OS Distributes computation logics among several physical processors.
  • The processors do not share memory or a clock.
  • Instead, each processor has its own local memory.
  • OS manages the communications between the processors. They communicate with each other through various communication lines.

Spooling


Spooling is an acronym for simultaneous peripheral operations on line. Spooling refers to putting data of various I/O jobs in a buffer. This buffer is a special area in memory or hard disk which is accessible to I/O devices. Operating system does the following activites related to distributed environment.
  • OS handles I/O device data spooling as devices have different data access rates.
  • OS maintains the spooling buffer which provides a waiting station where data can rest while the slower device catches up.
  • OS maintains parallel computation because of spooling process as a computer can perform I/O in parallel fashin. It becomes possible to have the computer read data from a tape, write data to disk and to write out to a tape printer while it is doing its computing task.

Distributed Environment Spooling



Advantages
  • The spooling operation uses a disk as a very large buffer.
  • Spooling is capable of overlapping I/O operation for one job with processor operations for another job.




Read full post »

What is an Operating System (OS)

0 comments

Operating System (OS)




    • An operating system (OS) is software that manages computer hardware and software resources and provides common services for computer programs. The operating system is an essential component of the systemsoftware in a computer system. Application programs usually require an operating system to function.

    • An operating System (OS) is an intermediary between users and computer hardware. It provides users an environment in which a user can execute programs conveniently and efficiently.

    • In technical terms, It is a software which manages hardware. An operating System controls the allocation of resources and services such as memory, processors, devices and information.


    Operating System Definition


    • An operating system is a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs.




    operating system notes



    Following are some of important functions of an operating System.
    • Memory Management
    • Processor Management
    • Device Management
    • File Management
    • Security
    • Control over system performance
    • Job accounting
    • Error detecting aids
    • Coordination between other software and users

    Memory Management


    • Memory management refers to 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.
    • Main memory provides a fast storage that can be access directly by the CPU. So for a program to be executed, it must in the main memory. Operating System does the following activities for memory management.

      • Keeps tracks of primary memory i.e. what part of it are in use by whom, what part are not in use.
      • In multiprogramming, OS decides which process will get memory when and how much.
      • Allocates the memory when the process requests it to do so.
      • De-allocates the memory when the process no longer needs it or has been terminated.

    Processor Management



    • In multiprogramming environment, OS decides which process gets the processor when and how much time. This function is called process scheduling. Operating System does the following activities for processor management.
      • Keeps tracks of processor and status of process. Program responsible for this task is known as traffic controller.
      • Allocates the processor(CPU) to a process.
      • De-allocates processor when processor is no longer required.

    Device Management



    • OS manages device communication via their respective drivers. Operating System does the following activities for device management.
      • Keeps tracks of all devices. Program responsible for this task is known as the 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. Operating System does the following activities for file management.
      • Keeps track of information, location, uses, status etc. The collective facilities are often known as file system.
      • Decides who gets the resources.
      • Allocates the resources.
      • De-allocates the resources.

    Other Important Activities in Operating System


    Following are some of the important activities that Operating System does.

    • Security -- By means of password and similar other techniques, preventing unauthorized access to programs and data.

    • Control over system performance -- Recording delays between request for a service and response from the system.

    • Job accounting -- Keeping track of time and resources used by various jobs and users.

    • Error detecting aids -- Production of dumps, traces, error messages and other debugging and error detecting aids.

    • Coordination between other softwares and users -- Coordination and assignment of compilers, interpreters, assemblers and other software to the various users of the computer systems.

    Read full post »

    Sunday, March 29, 2015

    Difference Compiler vs Interpreter in Programming Language

    0 comments


    Difference Compiler vs Interpreter 





    Compiler

    Interpreter

    Scans the entire program before translating it into machine code.


     Translates and executes the program line by line.



     Converts the entire program to machine code and only when all the syntax errors Removed does execution take place.

    Each time the program is executed; every line is
    checked for syntax error and then converted into
    the equivalent machine code. 

       

    Slow in debugging.


    Good for Fast debugging.

     Execution Time is less.

    Execution Time is more.                                                                                            
    Read full post »

    Difference Between call by value and call by reference

    0 comments


    Difference Between call by value and call by reference



     Call By Value
     Call By Reference
     Call by value return the value to the main function
     Call by reference return the address to the main function.


     Change in the sub function does not reflect to the main function
     Change in the sub function reflects to the main function.



     It can return only one value of variable.
     It can return more than one value of variables  because it return reference


     In Function call value is passed.
     In Function call address is passed.


     C and Java restrict themselves to Call by Value.
     C++ and Pascal let you declare that a parameter is a reference.



     Value of actual parameter is used to initialize the formal parameter.
     Formal parameter refers to the same memory cell for the actual     parameter.

    Read full post »

    Difference between array and linked list with Point

    0 comments


    Difference between array and linked list with Point




    Aspect
    Array
    Linked List
    Size
    ·        Fixed Number
    ·        Size need to be specific during declaration.
    ·        Grow and shrink since of insertions and deletions.
    ·        Maximum size depends on help.
    Storage Capacity
    Static  It’s location is allocated during compile time.
    Dynamic : It’s node allocated during run time.
    Order and Sorting
    Stored Consecutively
    Stored randomly
    Resizing
    Resizing is never necessary
    Resizing is necessary
    Access Mechanism
    Random access is efficient
    Random access is inefficient
    Accessing the Element
    ·        Direct or Random access method.
    ·        Specify the array index or subscript
    ·        Sequential access method
    ·        Traverse starting from the first node in the list by pointer.
    Searching
    Binary search and Linear search
    Linear search
    Memory Usage
    Wastes memory in unused positions
    Uses only the memory needed for the data actually in the list.
    Insert in Middle
    Insert in middle requires shifting
    Insert in middle is efficient after locating previous.
    Insert in beginning
    Add to beginning is costly.
    Add to beginning is fast.
    Insert in end
    Add to end is fast
    Add to end is costly if it is singly linked list.






    Read full post »