jueves, 25 de agosto de 2011

How to run a user programs in nachOS

Good nigh.

After a few tests with my team partners, we can run a user program in nachOS (for this we used nachOS 4.0 in C++), simple but is the first step in our way to complete one of the principal goals for the first presentation, the implementation of locks.

Here I'm gonna explain how we made it.

First of all, after you have installed nachOS, the cross compiler, and compiled nachOS correctly, you will going to move to the file called 'test' (hosted on the file 'code' of nachos4.0).



After you are on 'test' you have to create a document with .c extension. We will called it 'example.c'


Then, you can start to write the program, for this example we wrote:



syscall.h - make a call to nachOS system. Just let us call nachOS libraries, we can't call other libraries like unix or the library standard of C so we can't use functions as printf, scanf, etc.

We save the document, and return to the terminal.

Next thing you have to do is modify the Makefile for the compiler can create the executable file.

 

You will go to the end of Makefile and you will see the following part of text:



The only thing you have to do is copy one of those two parts and change the name of 'test1' for the name of your document, in this example 'example', and you will get something like this:



After that, save the changes on Makefile and now you are ready to compile and execute your example file.

For compile you just have to write 'make nameofyourfile'



¿No errors?, GOOD! now for execute you have to write:

' ../userprog/nachos -e nameofyourfile '

And we get our precious result (':


 

Hope this guide be useful for some of you which are using the same nachOS version and for those who are using other versions, try it and tell us if it's useful for others versions too :D 

¿Any doubt? Comment! :)

See ya!


References:
http://sopa.dis.ulpgc.es/wiki/index.php/Programas_de_usuario

No hay comentarios:

Publicar un comentario