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? पब्जी गेम

 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

A process scheduler schedules different process to be assigned to the CPU based on particular scheduling algorithms. In this section we will discuss about FCFS (First come First Server) Scheduling algorithm.

First Come First Serve (FCFS)
In this algorithm jobs are executed on first come, first serve basis. It is a non preemptive, preemptive scheduling algorithm. This algorithm is easy to understand and implement. Its implementation is based on FIFO queue. It is poor in performance as average wait time is high.


Example :
Consider following process and calculate average turnover FCFS algorithm.
= Solution
Gaint Chart
Average Waiting Time = Finished time - Arrival time - Brush time
                                     = (0+25+32)/3
                                     = 19
Average Turnaround Time = Finished time - Arrival time
                                           = (27+34+34)/3
                                           = 31.67

Device driver is the software that is responsible for communicating with device controller and reset of the operating system. Device drivers are vendor specific software and are provided by I/O device manufactures. It place vital role in making operating systems independent of I/O devices. Device manufactures are responsible for providing different drivers for different operating systems. This means separate device driver is needed for Windows, Linux, Sun Solaries, Unix etc.

Fragmentation refers to the condition of disk in which files are divided into pieces scattered around the disk. Fragmentation occurs naturally when we use a disk frequently, creating, deleting and modifying files.
There are two types of fragmentation

1. Internal Fragmentation 
  • It occurs with all memory allocation strategies. This is caused by the fact that memory is allocated in blocks of a fixed size, wheres the actual memory needed will rarely be that exact size. For a random distribution of memory requests, on the average 1/2 block will be wasted per memory request, because on the average the last allocated block will be only half null. 
  • Note that the same effect happens with hard drives, and that modern hardware gives us increasingly larger drives and memory at the expense of ever larger block size, which translate to more memory lost to internal fragmentation. 
  • Some system use variable size blocks to minimize losses due to internal fragmentation. 


2. External Fragmentation 
  • External fragmentation means that the available memory is broken up into lots of little pieces, none of which is big enough to satisfy the next memory requirement, although the same total could. 
  • All the memory allocation strategies suffer from external fragmentation, though first and best fits experience the problems more so than worst fit. The amount of memory lost to fragmentation may very with algorithm, usage patterns, and some design decision such as which end of a hole to allocate and which end to save on the free list. 
  • Statistical analysis of first fit, for example, shows that for N blocks of allocated memory, another 0.5 N will be lost to fragmentation. 
  • If the program in memory are relocatable, then the external fragmentation problem can be reduced via compaction, i.e. moving all processes down to one end of physical memory. This only involves updating the relocation register for each process, as all internal work is done using logical addresses. 


MKRdezign

Contact Form

Name

Email *

Message *

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