You will get the latest modified verson of Xv6 according to this repository here
Clone the official Xv6 repository from here. We need an emulator to boot Xv6.We will use qemu for this purpose. To install qemu, run from your terminal
sudo apt install qemu
Then from where Xv6 was cloned , run make to compile Xv6. Then to launch the emulator , run make qemu and you will see qemu in a different window. If qemu doesn't launch , then run
sudo apt install qemu-system-x86
make qemu
This time , it should work. Still, you might face problems like this then here is a way around.
To run qemu in the same terminal you're using , run make qemu-nox instead of make qemu.
After qemu is being launched , you will see following system calls by running ls

We can modify the source code and see the effects instantly.Lets say we want to replace the $ sign with something else.To do this , go to sh.c file and change inside getcmd method.
printf(2, ANSI_COLOR_GREEN "afnan@Xv6:$ " ANSI_COLOR_RESET);Add two lines at the top of this file
#define ANSI_COLOR_GREEN "x1b[32m"
#define ANSI_COLOR_RESET "x1b[0m"Now quit from the qemu terminal pressing cntrl+A , release and then type x immediately(as you can see it's a tedious task and we will create a system call to exit from the terminal).Then run make qemu-nox again and see the result now

The two CPU usage always seem to be 100%.To resolve this,do following modification.
In proc.c , modify schduler function
void
scheduler(void)
{
struct proc *p;
int ran;
struct cpu *c = mycpu();
c->proc = 0;
for(;;){
// Enable interrupts on this processor.
sti();
// Loop over process table looking for process to run.
acquire(&ptable.lock);
for(ran = 0, p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE)
continue;
// Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it
// before jumping back to us.
ran = 1;
c->proc = p;
switchuvm(p);
p->state = RUNNING;
swtch(&(c->scheduler), p->context);
switchkvm();
// Process is done running for now.
// It should have changed its p->state before coming back.
c->proc = 0;
}
release(&ptable.lock);
if (ran == 0) {
halt();
}
}
}and in x86.h , add a halt function
static inline void
halt()
{
asm volatile("hlt" : : );
}Let's create a system call to exit from the qemu terminal.We name it as shutdown.So we want to do something that would enable us to exit from the terminal by just writing the command shutdown.
First create a file named shutdown.c.
#include "types.h"
#include "stat.h"
#include "user.h"
int main(int argc, char * argv[])
{
printf(1, "Exitingn");
shutdown();
exit();//eq to return zero
}Notice that to print anything in console , we need to add a file descriptor as the first parameter of printf unlike C language.
Then in Makefile , add it in the UPROGS
UPROGS=
_cat
_echo
_forktest
_grep
_init
_kill
_ln
_ls
_mkdir
_rm
_sh
_stressfs
_usertests
_wc
_zombie
_shutdownAdd it also in EXTRA
EXTRA=
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c
ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c shutdown.cNow you can exit from the qemu terminal and run make qemu-nox again and see that ls will list shutdown as a system call.But running this command won't do anything for now.We've to add this system call to 4 following files
extern int sys_shutdown(void);
Then in the next block , add
[SYS_shutdown] sys_shutdown,#define SYS_shutdown 23SYSCALL(shutdown)void shutdown(void);Now,there are two files which contain the methods for system calls.sysfile.c contains methods related to files and sysproc.c contains methods related to processes.We have to write a new method named sys_shutdown in sysproc.c.
void sys_shutdown(void){
outw(0xB004, 0x0|0x2000);
outw(0x604, 0x0|0x2000);
}If everything's fine so far,then you can exit from qemu , run make qemu-nox and see the available sytem calls by running ls.Run the command shutdown and you will see the terminal exiting.

NB:I have already implemented few more sytem calls.You won't see add,incr,getsize etc for now if those aren't implemented.
First of all , modify the atoi function in ulib.c file so that it handles negative numbers too.