Wednesday, August 21, 2019

Operating System


Know more about Operating System...Click



What is Operating System?


The OS consists of many components and features. Which features are defined as part of the OS vary with each OS.

However, the three most easily defined components are:

KernelThis provides basic-level control over all of the computer hardware devices.

Main roles include reading data from memory and writing data to memory, processing execution orders, determining how data is received and sent by devices such as the monitor, keyboard and mouse, and determining how to interpret data received from networks.

User Interface: This component allows interaction with the user, which may occur through graphical icons and a desktop or through a command line. The user interface for mobile computers generally features a touch screen
{ GUI..Click & drag--- event-driven-----COM}
Application Programming Interfaces: This component allows application developers to write modular code.


However, the three most easily defined components are:

What is the difference between the UI and API?
An application program interface (API) is a set of routines, protocols, and tools for building software applications.

Basically, an API specifies how software components should interact. Additionally, APIs are used when programming graphical user interface (GUI) components.
UI- user communication


Basics of O.S

An operating system is a control program. A control program manages the execution of user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices.

An operating system as a resource allocator. A computer system has many resources that may be required to solve a problem:

Mobile operating systems often include not only a core kernel but also middleware : a set of software frameworks that provide additional services to application developers.


Middleware 
A typical operating system provides an application programming interface (API) for programs to utilize underlying hardware features. Middleware, however, provides an API for utilizing underlying operating system features.

Middleware is a software layer placed between applications and operating systems.


Bootstrap (Basic of O.S)

When it is powered up or rebooted—it needs to have an initial program to run. This initial program, or bootstrap program, tends to be simple. Typically, it is stored within the computer hardware in read-only memory (ROM)

The bootstrap program must know how to load the operating system and how to start executing that system. To accomplish this goal, the bootstrap program must locate the operating-system kernel and load it into memory.

Once the kernel is loaded and executing, it can start providing services to the system and its users.

Interrupt (Basic of O.S)

The occurrence of an event is usually signaled by an interrupt from either the hardware or the software. Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus. 
Software may trigger an interrupt by executing a special operation called a system call (also called a monitor call).

Generally, the table of pointers is stored in low memory (the first hundred or so locations).
These locations hold the addresses of the interrupt service routines for the various devices.
'C' -ISR (Interrupt Service Routine or interrupt handler.)


This array, or interrupt vector, of addresses is then indexed by a unique device number, given with the interrupt request, to provide the address of the interrupt service routine for the interrupting device.


system call (also called a monitor call).


A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel.

System call provides the services of the operating system to the user programs via Application Program Interface(API).

Services Provided by System Calls :
Process creation and management
Main memory management
File Access, Directory and File system management
Device handling(I/O)
Protection
Networking, etc.

system call (also called a monitor call).
Types of System Calls : There are 5 different categories of system calls –

Process control: end, abort, create, terminate, allocate and free memory.
File management: create, open, close, delete, read file etc.
Device management
Information maintenance
Communication

A typical operating system provides an application programming interface (API) for programs to utilize underlying hardware features. Middleware, however, provides an API for utilizing underlying operating system features.

Interrupt in C
VC++................... MFC












Java Programs

Simple Java Programs  

public class prg2 {

    public static void main(String[] args) {

        
        System.out.println("You entered:");
    }
}


public class prg1{

    public static void main(String[] args) {
        String str = "Welcome to Beginnersbook";
        String reversed = reverseString(str);
        System.out.println("The reversed string is: " + reversed);
    }

    public static String reverseString(String str)
    {
        if (str.isEmpty())
            return str;
        //Calling Function Recursively
        return reverseString(str.substring(1)) + str.charAt(0);
    }
}

public class prg3{

    public static void main(String[] args) {

        double number = 12.3;

        // true if number is less than 0
        if (number < 0.0)
            System.out.println(number + " is a negative number.");

        // true if number is greater than 0
        else if ( number > 0.0)
            System.out.println(number + " is a positive number.");

        // if both test expression is evaluated to false
        else
            System.out.println(number + " is 0.");
    }
}

public class prg5{

    public static void main(String[] args) {

        float first = 1.20f, second = 2.45f;

        System.out.println("--Before swap--");
        System.out.println("First number = " + first);
        System.out.println("Second number = " + second);

        // Value of first is assigned to temporary
        float temporary = first;

        // Value of second is assigned to first
        first = second;

        // Value of temporary (which contains the initial value of first) is assigned to second
        second = temporary;

        System.out.println("--After swap--");
        System.out.println("First number = " + first);
        System.out.println("Second number = " + second);
    }
}

public class prg6{
      public static void main(String args[]) {
         int a=5;
   while(a<10)   //while condition
         {
         System.out.println("value of a" +a);
         a++;
   System.out.println("aa");
         }
    }
}

public class prg7{
   public static String myClassVar="class or static variable";
   public static void main(String args[]){
      prg7 obj = new prg7();
      prg7 obj2 = new prg7();
      prg7 obj3 = new prg7();
      
      //All three will display "class or static variable"
      System.out.println(obj.myClassVar);
      System.out.println(obj2.myClassVar);
      System.out.println(obj3.myClassVar);

      //changing the value of static variable using obj2
      obj2.myClassVar = "Changed Text";

      //All three will display "Changed Text"
      System.out.println(obj.myClassVar);
      System.out.println(obj2.myClassVar);
      System.out.println(obj3.myClassVar);
   }
}

public class prg8{
      public static void main(String args[]) {
         int a=5;
   while(a<10)   //while condition
         {
         System.out.println("value of a" +a);
         a++;
   System.out.println("");
         }
    }
}

public class prg9{
    public static void main(String[] args) {
     int a=10;
     int b=5;
  
if(a>b)
      {  // if condition
     System.out.println(" A is greater than B");
      }
else
      {     // else condition
      System.out.println(" B is greater");
      }
}
}

public class prg10{ 
    public static void main(String[] args) {
     int week=2;
     String weeknumber;

switch(week){    // switch case
case 1:
          weeknumber="Monday";
       break;
     
case 2:
          weeknumber="tuesday";
       break;

case 3:
          weeknumber="wednesday";
       break;

default:        // default case
          weeknumber="invalid week";
       break;
     }
  System.out.println(weeknumber);
     } 
}


public class prg11{
      public static void main(String args[]){
          int count=1;
do {                        // do statement
     System.out.println("count is:"+count);
     count++;
   }
 while (count<10);
       }
  }

public class prg12{
      public static void main(String args[]) {
          for(int i=0; i<=10; i++)  // for condition  
          {
          System.out.println(i);
          }
     }
}


import java.util.Scanner;
class prg13{
    public static void main(String[] args) {
    
     Scanner input = new Scanner(System.in);
    
     System.out.print("Enter an integer: ");
     int number = input.nextInt();
     System.out.println("You entered " + number);
    }
}