domingo, 27 de noviembre de 2011



Links where I information support:
http://cs.nyu.edu/~yap/classes/compsys2/nachos/x326.html
http://gift.sourceforge.net/docs/0.11.x/libgift/network_8h.html

NachOs OS Network



In this part I Network.cc explained.

lunes, 7 de noviembre de 2011

Practical Part II


Practical Part II


Using the file system functions




and here's the video about the slides


On the video.

1- check for the DISK of nachos ( the simulated HDD).
2- use the nachos -f to force the format of the hdd and there's no hdd then nachOS create one.
3- nachos create a new DISK with 5000bytes of space
4- Enter in /nachos/code/machine/disk.cc and modify the magicsize if you want more space
5- use nachos -cp to copy the halt program into the nachos DISK
6- use nachos -l to see the content of the DISK in this case only the file ALTO
7- now use nachos -x to execute  the program from nachos DISK
8- now copy one file to the DISK
9- use nachos -p to print the content of the file
10- that's all.



lunes, 31 de octubre de 2011

Java Stacks

Well we all know what batteries are in Java, but explain a little as we will need in the implementation of Nachos.

The first is to define the stack, ie, instantiate the class Stack.

Stack pila = new Stack();

When using a string, we mean what are strings.
The method that inserts elements in the stack is. Push (). This method will receive as a parameter the element to be inserted.

for (int x=1;x<=10;x++) pila.push(Integer.toString(x));

We have created a loop that we will create the numbers and we have relied on the Integer class and method. ToString () to convert numbers to strings.

Once we have all the elements, we proceed to drain the battery. We will have to interact on the stack until it is empty, which tells us the method. Empty (). In each iteration we extract an item from the stack using the method. Pop ().

while (!pila.empty())
System.out.println(pila.pop());



This is the code:

import java.util.*;
public class Pilando {
Stack pila = new Stack();
public void ingresar()
{
for (int x=1;x<=3;x++) { pila.push(Integer.toString(x)); } } public void sacar() { while (this.empty() == 1) { System.out.println("Sacando el elemento "+pila.pop()); } System.out.println("La pila esta vacía!!!"); } public void show1() { System.out.println("El primer elemento agregado es ---> "+pila.firstElement().toString());
}
public void show2()
{
System.out.println("El ultimo elemento agregado es ---> "+pila.lastElement().toString());
}
public void show3()
{
System.out.println("La cantidad de elementos es de ---> "+pila.size());
}
public int empty()
{
int valid = 1;
if(!pila.empty())
{
valid = 1;
}
else
if(pila.empty())
{
valid = 0;
}
return valid;
}
}

Analysis Algorithm

An algorithm is a finite set of unambiguous and effective instructions that indicate how to solve a problem, produce at least one outlet, receive zero or more inputs and to run, require a finite amount of resources.
The selection criteria are defined by CPU time, this implies that the program will be more efficient is faster.

For example Quicksort



In this case the strategy is to take an item and put in a pivotal part to the minor elements to the pivot and the other to those over the pivot. After recursive calls are made to order both parties. In this case also takes advantage of the fact that an array of size 1 isalready sorted.
The algorithm that starts the settlement into two parts (not equal) is defined in the algorithm 21. This algorithm part of the settlement into two parts using the first array element as a pivot.

In this case using the asymptotic analysis, we define:

Size of the problem: The array size
Basic Operation: Comparisons
To make the temporal analysis we noticed that the partitionalgorithm performs n comparisons. Informally this is because the pivot is compared against all array elements. We analyze each case quicksort.
Worst Case: Occurs when the pivot is the first element
Best case: The pivot is exactly half
In this case the array is divided into two parts of equal size.Assuming that n = 2k each party will have a size 2k 1 (for the pivot is now in order.)







Bibliography

- Thomas H. Cormen , Introduction to Algorithms, Mc Graw Hill, 2000
- Harel D., Algorithmics The Spirit of Computing, Addison Wesley, Segunda Edición, 1992
- Horowitz E., S. Sahni, Fundamentals of Computer Algorithms, Potomac, Maryland: Computer Science Press, Inc, 1978