Wednesday, 15 November 2017

You know what, sometimes I feel like I don't even care what happens.
I don't feel like making an effort sometimes

After all it's all just fate right, or do we have free will?
A man's walking in a storm and a tree falls on him
He dies.
Was it predestined, or was it his steps that led him below the tree?
Maybe right? There is no right answer

But sometimes I just wanna make an effort
After all our fate is in our hands
We can keep fighting
I've an exam tomorrow
Will fate decide my marks? Maybe
If I study will I get more marks? Definitely

What if I study and fate decides to give what I didn't study?
My answer was given by mathematics in the end
1. If you study and fate messes you up. You lose
2. If you study and fate helps you. You win

You've half a chance of making it

1. If you don't study and fate messes you up. You lose
2. If you don't study and fate helps you. You lose

You've no chance of making it

I think I'm gonna study now~

Friday, 22 September 2017

Errors while installing PintOS

So, I'm taking an Operating Systems course and I choose to do the PintOS assignments/projects by Stanford (http://www.scs.stanford.edu/17wi-cs140/labs/project.html).

Anyway, I've decided to document the problems I faced or will face as I go through the project.
I'm using VirtualBox and ubuntu-gnome-16.04.1-desktop-amd64. PintOS will run on top of qemu emulator.

Note- This is not a guide to installation, it's merely a note of the problems I faced and for someone who faces the same problem and save time.

I'm just gonna provide some links that I followed to install it-
1. https://tssurya.wordpress.com/2014/08/16/installing-pintos-on-your-machine/
2. https://pintosiiith.wordpress.com/2012/09/13/intall-pintos-with-qemu/
3. http://krharsha.blogspot.in/2013/08/pintos-installation.html

As you can see the second one is quite old and hence you need to go through all the three of the guides

Prerequisites

The following packages need to be installed on your system:
1. GCC
2. GNU binutils
3. Perl
4. GNU make
5. QEMU; "If QEMU is not available, Bochs can be used, but its slowness is frustrating."
6. GDB

Installation

In the subsequent text, $HOME will refer to your home directory, wherever you create a folder for pintos.
Once the prerequisites have been installed, do the following steps:

1. Download Pintos:
Download the pintos source code here . Extract it in some directory, say $HOME/os .

2. Set GDBMACROS
Open the script 'pintos-gdb' (in $HOME/os/pintos/src/utils) in any text editor. Find the variable GDBMACROS and set it to point to $HOME/os/pintos/src/misc/gdb-macros .
Remember to replace $HOME with the actual path.

3. Compile the utilities
Change to the utils folder, if not already there, and compile the utilities by typing

make

on the terminal.
If you get an error saying "Undefined reference to ‘floor' ", make the following changes; edit 'Makefile' in the current directory and replace "LDFLAGS = -lm" by "LDLIBS = -lm". Recompile now, it will work.

4. Edit Make.vars in /threads
Edit the file 'Make.vars' in the 'threads' directory ( $HOME/os/pintos/src/threads ); change the last line to:
SIMULATOR = --qemu

5. Compile Pintos kernel
Change to the 'threads' directory, if not already there, and run 'make' to compile the pintos kernel.

6. Edit the pintos utility
Make these changes in the 'pintos' file at $HOME/os/pintos/src/utils/':
    a) On line number 103, change 'bochs' to 'qemu'.
    b) On line number 259, change 'kernel.bin' to the actual path at '$HOME/os/pintos/src/threads/build/kernel.bin'.

7. Edit pintos.pm file
Open the file '$HOME/os/pintos/src/utils/Pintos.pm' in the editor and at line number 362, change "loader.bin" to the actual path to the file at '$HOME/os/pintos/src/threads/build/loader.bin'.

8. Create qemu link
You need to create a link to the QEMU executable on your system; these will generally be found in '/usr/bin'. If it is not there search the $PATH folders for it. Whichever directory you find it, change to that directory and type the following command:

ln -s qemu-system-i386 qemu

This will create a link 'qemu' to the QEMU executable.
Restart the terminal for changes to take effect.

9. Run Pintos
Go to the 'utils' directory at '$HOME/os/pintos/src/utils/' and run pintos with the following command:

./pintos run alarm-multiple

Now you are all set to get hacking away with Pintos.
If you face some errors or have doubts, please feel free to comment below.

Problem 1- While running pintos run alarm-multiple you get some SIGVTALRM, Constant routine and prototype mismatch error.

Solution - Turns out to solve this you just need to go to the pintos file in src/utils/ and then comment out the whole SIGVTALRM function. It was at line 925 in my case but you can always use Ctrl+F.

https://stackoverflow.com/questions/38989352/pintos-installation-sigvtalrm-redefined-error



Problem 2- While running pintos run alarm-multiple you get Cannot find Kernel error.

Solution - You must've used "$HOME/os-pg/pintos/src" in the pintos and Pintos.pm file. Thing is Perl can't understand the "$" or "~" so, you need to write the absolute path.

To find the absolute path, just open up the terminal and type 'echo $HOME'. The output should be something like this

Now open up the pintos file in src/utils and then replace the $HOME here


 By whatever your absolute directory is, like this.

Do the same in Pintos.pm file.
Save the files and restart the terminal. It should be working now


(P.S. - No matter how many guides are there, you'll face problems and you need to invest around 3 to 4 hours, unless you're lucky to be able to install it without a glitch
You need to go through the comments of the blogs and other stuff to find answers to your problem cause it's very rare that you'll face a problem that anyone else hasn't already faced before.)