Computer Notes, Programming codes, Hardware and Networking Tip, Entertainment, Biography, Internet Tip, Tech News, Latest Technology, YouTube,

Latest Post
About RAM Advantages of multiprocessing system Associative memory Binary Number System CA CA Notes Change drive icon change pendrive icon Computer Abbreviation Computer Architecture Computer fundamental MCQ Computer Generation Computer generation computer notes Computer MCQ Computer Network MCQ Computer Operator MCQ Critical Section Critical section in OS Database connectivity in java Deadlock avoidance Deadlock detection algorithm Deadlock Detection and Recovery Deadlock detection method Deadlock Handling Deadlock in OS Deadlock Prevention Deadlock Recovery define object and class Define system cell Descrete Structure Device Driver Device driver in computer device driver in os DFA DFA contains with DFA ends with dfa examples dijkstra's algorithm Discrete Structure Discrete Structure graph theory Download JDBC Driver Download MySql Download PUBG DS DS Notes FCFS Job Scheduling Algorithm Finding shortest path Finite Sate Automata Flynn's Classifications fragmentation in computer fragmentation in harddisk fragmentation in os fragmented memory Full form related to computer Generations of operations Generations of OS Graph theory ICT 1st semester notes Instruction Address Modes Java java array declaration java class and object example Java Database connectivity example java event handling example program Java JDBC Java JMenuBar Java JSP program example java notes java program methods example Java program to create class and object java program to create methods java program to print even number between any two numbers Java programming java programming notes Java programs Java question answer java swing example java swing program to calculate simple interest Java Tutorials JSP program learn qbasic Lekh MCQ MCQ Computer MCQ Operating System memory fragmentation MICT 1st semester notes mict 1st semester operating system notes MICT first semester notes Multiprocessing mutex in os Necessary conditions for deadlock Number System Operating System Operating system notes OS OS Notes OS Numeric pattern printing program in qbasic patterns in qbasic Pipeline Hazards Pipelining Pipelining concept prime or composite in qbasic print patterns qbasic print series in qbasic Printing Series in qbasic PUBG PUBG Mobile PUBG PC PUBG Story qbasic qbasic code qbasic for class 10 qbasic for class 8 qbasic for class 9 qbasic for school QBASIC Pattern printing qbasic pattern printing program qbasic pattern printing programs qbasic pattern types qbasic patterns qbasic programming tutorials qbasic programs qbasic sequence printing programs qbasic tutorials Race Condition in Operating system reverse order in qbasic RISC and CISC RISC Pipeline Scheduling algorithm segmentation in operating system segmentation in os semaphore and mutex Semaphore concept in os Semaphore in os semaphore in os notes semaphore meaning sequential programs in qbasic series in qbasic series printing programs in qbasic shell in operating system shell in os shortest path shortest path algorithm simple interest program in java swing System Bus System Cell Teach Blog Tech Blog Tech School technical school The Shell in Operating system types of fragmentation Types of Multiprocessor types of operating system Types of pipeline hazards View Connected Wifi password Virtual Memory Virtual memory in OS Von Neumann's architecture What is associative memory? what is class? What is computer system? What is Fragmentation? What is jsp? what is object? What is process? What is segmentation What is System Cell What is Thread? what is virtual memory in computer What is virtual memory? पब्जी गेम

JSP is a Java Server side technology that does all the processing at server. It is used for creating dynamic web application using Java as programming language.

JSP Program to print "I Love Programming" 100 times.



Program
 
<!DOCTYPE html>
<html> 
<head> 
 <meta http-equiv="Content-Type" content="text/html" charset=UTF-8">
 <title> A simple JSP program </title> 
</head> 
<body> 
 <h1> Displaying "I love Programming 100 times !!" </h1> 
 <table> 
  <% for(int i=1; i<=100; i++){ %> 
   <tr> <td> I Love Programming </td> </tr> 
  <% } %>
 </table> 
</body> 
</html> 


Output of the given Java program

Program

 

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;       

class PTR extends JFrame implements ActionListener //implement listener interface
{
 JTextField t1, t2, t3, t4;
 JLabel l1,l2,l3, l4;
 JButton b1; 
 public PTR() 
 {
  super("Handling Action Event");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        l1 = new JLabel("Enter P :");
  l2 = new JLabel("Enter T :");
  l3 = new JLabel("Enter R : ");
  l4 = new JLabel("Interest : ");
  t1 = new JTextField(10);
  t2 = new JTextField(10);
  t3 = new JTextField(10);
  t4 = new JTextField(10); 
  b1 = new JButton("Calculate");
  
  setLayout(new FlowLayout(FlowLayout.LEFT,150,10));
        add(l1);
  add(t1);
  add(l2);
  add(t2);
  add(l3);
  add(t3);
  add(l4);
  add(t4); 
  add(b1);

  b1.addActionListener(this);//Registering event

  setSize(400,300);
        setVisible(true);
 }
 
 public void actionPerformed(ActionEvent ae) //Handle Event
 {
  int p, t, r, si; 
  p = Integer.parseInt(t1.getText());   
  t = Integer.parseInt(t2.getText()); 
  r = Integer.parseInt(t3.getText());
  if(ae.getSource() == b1)
   si = (p*t*r)/100;
  else
   si = 0; 

  t4.setText(String.valueOf(si));
 }

 public static void main(String a [])
 {
  new PTR();
 }
}


Array is a data structure which contains of similar data type. We store only fixed set of elements in a java array. Array is used to store a collection of data, but it is often more useful to think of an array as a collection of variable of the same type.

To declare an array in a Java program, we must declare a variable to reference the array and we most specify the type of array the variable can reference.
Syntax:
                 dataType[] arrayRefVar;
                      or
                 dataType arrayRefVar[];


Program
 

import java.util.Scanner; 
class EvenArray{
     public static void main(String args[]){
 Scanner in = new Scanner(System.in); 
 int x, y; 
 System.out.print("Enter First Number : "); 
 x = in.nextInt(); 
 System.out.print("Enter Second Number : "); 
 y = in.nextInt(); 

 for(int i=x; i<=y; i++){
      if(i%2==0){
     System.out.println(i); 
      }
 }
     }
}


 The thread is a lightweight process that means one single program can be divided into small threads which will execute concurrently for fast execution of task. We can say that thread is a sub process of a process.

A thread is an independent path of execution within a program. Many thread can run concurrently within a program. Every threads in Java is created and controlled by the java.lang thread class. A java program can have many threads, and these threads can run currently, either synchronously or asynchronously.

 - Threads are lightweight compared to process.

Difference between thread and process

Process Thread
- A Process is an instance of a program. It contains a threads. - Threads are the parts of process. It cannot contain a process.
- Process run in its separate. - Thread run in shared memory spaces.
- Process is controlled by the operating system. - Threads a re controlled by programmer in a program.
- Processes are independent.  - Threads are dependent. 
- New processes require duplication of the parent process.  - New threads are easily created.
- Process require more time for context switching as they are more heavy. - Threads require less time for context switching as they are lighter then process. 
- Process require more resources then threads.  - Threads generally need less resources than process. 
- Process require more time for termination. - Threads require less time for termination.

 Life cycle of threads

 

New
The thread is in new state if you create an instance of thread class but before the invocation of start() method.

Runnable
A thread in the runnable state is executing the Java virtual machine but it may be waiting for other resources from the operating system such as processor.

Running
The thread is in running state if the thread scheduler has selected it.

Blocked (Non Runnable)
It is the state when the thread is still alive, but is currently not eligible to run.

Terminated
A thread is in terminated or dead state when its run() method exists.

Write a Java program to create a form with student id, student name, level, and two button insert and clear. Handle the event such that buttons with perform the operations as implied by their name.




 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Student extends JFrame implements ActionListener
{
 JLabel sid,sname,slevel;
 JTextField tid,tname, tlevel;
 JButton insert, clear;
 JPanel p1,p2,p3,p4;
 Student()
 {
  setSize(400,250);
  setTitle("Students Data Entry");
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  p1=new JPanel();
  p2=new JPanel();
  p3=new JPanel();
  p4=new JPanel();

  setLayout(new BorderLayout());
  add(p1,BorderLayout.CENTER);
  add(p2,BorderLayout.SOUTH);
  p1.setLayout(new GridLayout(1,2));
  p1.add(p3);
  p1.add(p4);

  p3.setLayout(new FlowLayout(FlowLayout.LEFT, 75,20));
  p4.setLayout(new FlowLayout(FlowLayout.LEFT, 25,20));
  sid=new JLabel("Student ID");
  sname=new JLabel("Student Name");
  slevel=new JLabel("Level");
  p3.add(sid);
  p3.add(sname);
  p3.add(slevel);
  tid=new JTextField(10);
  tname=new JTextField(10);
  tlevel=new JTextField(10);
  p4.add(tid);
  p4.add(tname);
  p4.add(tlevel);
  p2.setLayout(new FlowLayout(FlowLayout.CENTER, 20,20));
  insert=new JButton("Insert");
  clear=new JButton("Clear");
  
                p2.add(insert);
  p2.add(clear);
  
  insert.addActionListener(this);
  clear.addActionListener(this);
    
  setVisible(true);
 }
 public void actionPerformed(ActionEvent ae)
 {
  Connection c=null;
  Statement s=null;
  try
  { 
   Class.forName("com.mysql.jdbc.Driver");
c = DriverManager.getConnection("jdbc:mysql://localhost/mydb","root", "raj");
   s=c.createStatement();
   if(ae.getSource()==insert)
   {
           int id;
                                String name, level;
    id=Integer.parseInt(tid.getText());   
                                name=tname.getText();
    level=tlevel.getText();
    
  String query="insert into studentdb values("+id+",'"+name+"',"+level+")";
    s.executeUpdate(query);
  JOptionPane.showMessageDialog(this,"Data is Recorded!!!!");
   
   }
   
   if(ae.getSource()==clear)
   {
                            tid.setText("");  
                            tname.setText(""); 
                            tlevel.setText("");
   }
  }
  catch(Exception e)
  {
                    System.out.println(e);
  }
 }
 public static void main(String a[])
 {
  new Student();
 }
}






Multiprocessing is the use of two or more central processing unit within a single computer system. The term also refers to the ability of a system to support more than one processor or the ability to allocate task between them. Multiprocessor is a computer system having two or more processing units each sharing main memory and peripherals, in order to simultaneously process programs.


Multiprocessing however means using more than one processor. However, multiprocessor or parallel system are increasing in importance nowadays. These systems have multiple processors working the parallel that share the computer clock, memory bus, peripheral devices etc. The following figure demonstrate the multiprocessor architecture as

Types of Multiprocessors

There are mainly two types of multiprocessor i.e symmetric and asymmetric multiprocessors.
1. Symmetric Multiprocessor
In this type of multiprocessor each runs an identical copy of the OS and these copies communicate with one another as needed. All Processor are peers. Examples are Windows NT, Sun Solaries, Digital Unix, OS/2 and Linux.

2. Asymmetric multiprocessor
In this multiprocessor each processor is assigned a specific task. A master processor controls the system; the other processor look to the master for instructions or predefined tasks. It defines a master-slave relationship. Example Sun OS version 4.
Asymmetric multiprocessor was the only one type of multiprocessor available before symmetric multiprocessor were created. Now also, this has cheaper option.


Advantages of multiprocessor systems 

  • More reliable system (Ability to continue working if any CPU fails) 
  • Enhanced Throughput 
  • More Economic systems
  • Increased Expense 
  • Complicated Operating system required 
  • Large main memory required 

Flynn's Classification 


  • In 1966, Flynn's proposed or classified the computer architecture into 4 types. So this concept known as Flynn's classification. 
  • This classification has been used as a tool in the design of modern processors and their functionalities. 
  • Due to Flynn's classification the multiprocessing and multiprocessing concept has evolved. 
  • Flynn's classified the system into four types that is based upon the number of current instruction streams and data streams available in the architecture . 

Flynn's Classifications


Single Instruction Single Data (SISD) System 


  • It is Uni-processor machine 
  • It executes a single instruction which operate on a single data stream. 
  • In SISD, machine instructions are processed in a sequential manner, So it is known as sequential computers. 
  • It this the speed of the processing element in the SISD model is limited or dependent on the rate at which the information is transformed. 
SISD Uni-Processor Architecture
Captions 
CU - Control Unit                    PU - Processing Unit
MU - Memory Unit                 IS - Instruction Stream  
DS - Data Stream 

Single Instruction Multiple Data (SIMD) Systems 


  • SIMD is multiprocessor system. 
  • It execute the instruction on all the CPU's but operate on different data streams. 
  • SIMD model is well suited to scientific operations. So that the information can be passed to all the processing elements organized data elements of vectors can be divided into multiple sets (N sets for N PE system) and each PE can process on data set. 
  • SIMD system is cray's vector processing machine. 
SIMD Architecture (With Distributed Memory) 
Captions : 
CU - Control Unit                     PU - Processing Unit
MU - Memory Unit                  IS - Instruction Stream
DS - Date Stream                      PE - Processing Element 
LM - Local Memory 

Multiple Instruction Single Data (MISD) Systems 


  • It is a multiprocessor machine 
  • It execute different instructions on different PE (Processing Element) but all of the operates on the same data set. 
                      Example ; sin(x) + cos(x) + tan(x)
  • It performs different operations on the same data set. 
  • The computer system built using the MISD model are not useful in most of the applications. 
MISD Architecture (The systolic Array) 
Captions
CU - Control Unit,          PU- Processing Unit,            MU- Memory Unit, 
IS - Instruction Stream,          DS-Data Stream,             PE - Processing Element
LM - Local Memory 


Multiple Instruction Multiple Data (MIMD) Systems)


  • This system is multiprocessor machine
  • It executes multiple instructions on multiple data sets. 
  • In this, each processing elements (PE) has separate instruction and data streams
  • The computer system built using the MIMD model are capable for all types of applications
  • In this processing elements (PE) work asynchronously while SIMD and MISD machine doesn't work asynchronously 
MIMD Architecture (With shared Memory)
Captions: 
CU - Control Unit                 PU - Processing Unit
MU - Memory Unit               IS - Instruction Stream
DS - Data Stream                  PE - Processing Element
LM - Local Memory

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget