August 30, 2010

Oprating System :Scheduling Criteria

CPU utilization – keep the CPU as busy as possible
Throughput – # of processes that complete their execution per time unit
Turnaround time – amount of time to execute a particular process
Waiting time – amount of time a process has been waiting in the ready queue
Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)


Formula
Waiting time (WT)=start time(ST)-Arrival time (AT)
Finish time (FT)=start time(ST)+Burst Time(BT)
Total turn around time(TOT)=Finish time(FT)-Arrival time (AT )

August 10, 2010

This is called an attitude

One night President Obama and his wife Michelle decided to do something out of routine and go for a casual dinner at a restaurant that wasn't too luxurious. When they were seated, the owner of the restaurant asked the president's secret service if he could please speak to the First Lady in private. They obliged and Michelle had a conversation with the owner. Following this conversation President Obama asked Michelle, why was he so interested in talking to you. She mentioned that in her teenage years, he had been madly in love with her. President Obama then said, "so if you had married him, you would now be the owner of this lovely restaurant" , to which Michelle responded, "no, if I had married him, he would now be President"

June 18, 2010

30 second Speech by Bryan Dyson (CEO of Coca Cola)

"Imagine life as a game in which you are juggling some five balls in the air. You name them - Work, Family, Health, Friends and Spirit and you're keeping all of these in the Air.

You will soon understand that work is a rubber ball. If you drop it, it will bounce back.

But the other four Balls - Family, Health, Friends and Spirit - are made of glass. If you drop one of these; they will be irrevocably scuffed, marked, nicked, damaged or even shattered. They will never be the same.
You must understand that and strive for it."

WORK EFFICIENTLY DURING OFFICE HOURS AND LEAVE ON TIME. GIVE THE REQUIRED TIME TO YOUR FAMILY, FRIENDS & HAVE PROPER REST.

"VALUE HAS A VALUE ONLY IF ITS VALUE IS VALUED"

March 22, 2010

Command-line arguments in the C language

Command-line arguments in the C language
The C language provides a method to pass parameters to the main() function. This is typically accomplished by specifying arguments on the operating system command line (console).
The prototype for main() looks like:
int main(int argc, char *argv[])
{

}
There are two parameters passed to main(). The first parameter is the number of items on the command line (int argc). Each argument on the command line is separated by one or more spaces, and the operating system places each argument directly into its own null-terminated string. The second parameter passed to main() is an array of pointers to the character strings containing each argument (char *argv[]).
For example, at the command prompt:
test_prog 1 apple orange 4096.0

There are 5 items on the command line, so the operating system will set argc=5 . The parameter argv is a pointer to an array of pointers to strings of characters, such that:
argv[0] is a pointer to the string “test_prog”
argv[1] is a pointer to the string “1”
argv[2] is a pointer to the string “apple”
argv[3] is a pointer to the string “orange”
and argv[4] is a pointer to the string “4096.0”
Notes
• The main() routine can check argc to see how many arguments the user specified.
• The minimum count for argc is 1: the command line just contained the name of the invoked program with no arguments.
• The program can find out its own name as it was invoked: it is stored in the argv[0] string! Some operating systems don't provide this feature, however.
• The arguments from the command line are not automatically converted: the characters are just copied into the argv strings.

• If an argument on the command line is to be interpreted as a numerical constant, such as argv[1] and argv[4] in this example, it can be converted using a string conversion.
int int_val; float float_val;
sscanf(argv[1],”%d”,&int_val);
sscanf(argv[4],”%f”,&float_val); and
printf(“The 3rd and 4th items on the command line are %s and %s\n”, argv[2], argv[3]);
results in: The 3rd and 4th items on the command line are apple and orange
The string functions atoi(), atol(), atof(), etc., will also work.

February 15, 2010

Java Menu

Hi
friend As i commit u ppl I m giving you code of menu with action on menu
Hope so this code will help u in ur project

Prof.Prasad Sawant


/* BY
Prof.Prasad Sawant
BCA
Prof .Ramkrishana More A.C.S College */
import java.awt.*;
import java.awt.event.*;

import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import javax.swing.ImageIcon;

import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JFrame;


//Used Action Listner for JMenuItem & JRadioButtonMenuItem
//Used Item Listner for JCheckBoxMenuItem

public class JMenuDemo implements ActionListener, ItemListener{
JTextArea jtAreaOutput;
JScrollPane jspPane;

public JMenuBar createJMenuBar() {
JMenuBar mainMenuBar;
JMenu menu1, menu2, submenu;
JMenuItem plainTextMenuItem, textIconMenuItem, iconMenuItem, subMenuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;
ImageIcon icon = createImageIcon("jmenu.jpg");

mainMenuBar = new JMenuBar();

menu1 = new JMenu("Menu 1");
menu1.setMnemonic(KeyEvent.VK_M);
mainMenuBar.add(menu1);

//Creating the MenuItems
plainTextMenuItem = new JMenuItem("Menu item with Plain Text",
KeyEvent.VK_T);
//can be done either way for assigning shortcuts
//menuItem.setMnemonic(KeyEvent.VK_T);

// Accelerators, offer keyboard shortcuts to bypass navigating the menu hierarchy.
plainTextMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_1,
ActionEvent.ALT_MASK));
plainTextMenuItem.addActionListener(this);
menu1.add(plainTextMenuItem);


textIconMenuItem = new JMenuItem("Menu Item with Text & Image", icon);
textIconMenuItem.setMnemonic(KeyEvent.VK_B);
textIconMenuItem.addActionListener(this);
menu1.add(textIconMenuItem);

//Menu Item with just an Image
iconMenuItem = new JMenuItem(icon);
iconMenuItem.setMnemonic(KeyEvent.VK_D);
iconMenuItem.addActionListener(this);
menu1.add(iconMenuItem);

menu1.addSeparator();
//Radio Button Menu items follow a seperator

ButtonGroup itemGroup = new ButtonGroup();

rbMenuItem = new JRadioButtonMenuItem("Menu Item with Radio Button");
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_R);
itemGroup.add(rbMenuItem);
rbMenuItem.addActionListener(this);
menu1.add(rbMenuItem);

rbMenuItem = new JRadioButtonMenuItem("Menu Item 2 with Radio Button");
itemGroup.add(rbMenuItem);
rbMenuItem.addActionListener(this);
menu1.add(rbMenuItem);

menu1.addSeparator();
//Radio Button Menu items follow a seperator
cbMenuItem = new JCheckBoxMenuItem("Menu Item with check box");
cbMenuItem.setMnemonic(KeyEvent.VK_C);
cbMenuItem.addItemListener(this);
menu1.add(cbMenuItem);

cbMenuItem = new JCheckBoxMenuItem("Menu Item 2 with check box");
cbMenuItem.addItemListener(this);
menu1.add(cbMenuItem);

menu1.addSeparator();
//Sub Menu follows a seperator
submenu = new JMenu("Sub Menu");
submenu.setMnemonic(KeyEvent.VK_S);

subMenuItem = new JMenuItem("Sub MenuItem 1");
subMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2,
ActionEvent.CTRL_MASK));
subMenuItem.addActionListener(this);
submenu.add(subMenuItem);

subMenuItem = new JMenuItem("Sub MenuItem 2");
submenu.add(subMenuItem);
subMenuItem.addActionListener(this);
menu1.add(submenu);

//Build second menu in the menu bar.
menu2 = new JMenu("Menu 2");
menu2.setMnemonic(KeyEvent.VK_N);
mainMenuBar.add(menu2);

return mainMenuBar;
}

public Container createContentPane() {
//Create the content-pane-to-be.
JPanel jplContentPane = new JPanel(new BorderLayout());
jplContentPane.setLayout(new BorderLayout());//Can do it either way to set layout
jplContentPane.setOpaque(true);

//Create a scrolled text area.
jtAreaOutput = new JTextArea(5, 30);
jtAreaOutput.setEditable(false);
jspPane = new JScrollPane(jtAreaOutput);

//Add the text area to the content pane.
jplContentPane.add(jspPane, BorderLayout.CENTER);

return jplContentPane;
}

/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = JMenuDemo.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find image file: " + path);
return null;
}
}

private static void createGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);

//Create and set up the window.
JFrame frame = new JFrame("JMenu Usage Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JMenuDemo app = new JMenuDemo();
frame.setJMenuBar(app.createJMenuBar());
frame.setContentPane(app.createContentPane());

frame.setSize(500, 300);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Menu Item source: " + source.getText()
+ " (an instance of " + getClassName(source) + ")";
jtAreaOutput.append(s + "\n");
jtAreaOutput.setCaretPosition(jtAreaOutput.getDocument().getLength());
}

public void itemStateChanged(ItemEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
String s = "Menu Item source: " + source.getText()
+ " (an instance of " + getClassName(source) + ")"
+ "\n"
+ " State of check Box: "
+ ((e.getStateChange() == ItemEvent.SELECTED) ?
"selected":"unselected");
jtAreaOutput.append(s + "\n");
jtAreaOutput.setCaretPosition(jtAreaOutput.getDocument().getLength());
}

// Returns the class name, no package info
protected String getClassName(Object o) {
String classString = o.getClass().getName();
int dotIndex = classString.lastIndexOf(".");
return classString.substring(dotIndex+1); //Returns only Class name
}

public static void main(String[] args) {

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createGUI();
}
});
}


}

Java Swing Handbook

Swing Handbook