LAB 2 CSE 660 Submitted By: Arumugam Thendramil...

15
LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavai Steps to install Xv6 in CentOS 7 Copied the source code by using the git clone command, git clone git://github.com/mit-pdos/xv6-public.git Copied to a folder named lab2 cp -r xv6-public/ Documents/lab2 Installed QEMU using the following commands [root@localhost qemu]# git clonegit://git.qemu-project.org/qemu.git [root@localhost qemu]# ./configure [root@localhost qemu]# make [root@localhost qemu]# make install Found the Path for QEMU using 'which' command [root@localhost qemu]# which qemu-system-i386 /usr/local/bin/qemu-system-i386

Transcript of LAB 2 CSE 660 Submitted By: Arumugam Thendramil...

Page 1: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

LAB 2 CSE 660

Submitted By: Arumugam Thendramil Pavai

Steps to install Xv6 in CentOS 7

Copied the source code by using the git clone command,

git clone git://github.com/mit-pdos/xv6-public.git

Copied to a folder named lab2

cp -r xv6-public/ Documents/lab2

Installed QEMU using the following commands

[root@localhost qemu]# git clonegit://git.qemu-project.org/qemu.git

[root@localhost qemu]# ./configure

[root@localhost qemu]# make

[root@localhost qemu]# make install

Found the Path for QEMU using 'which' command

[root@localhost qemu]# which qemu-system-i386

/usr/local/bin/qemu-system-i386

Page 2: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

In the Makefile for Xv6 changed the path for QEMU

QEMU = /usr/local/bin/qemu-system-i386

open terminal in lab2 folder which contains files for Xv6

Script for running Xv6

[root@localhost lab2]# make qemu-nox

dd if=/dev/zero of=xv6.img count=10000

10000+0 records in

10000+0 records out

5120000 bytes (5.1 MB) copied, 0.095689 s, 53.5 MB/s

dd if=bootblock of=xv6.img conv=notrunc

1+0 records in

1+0 records out

512 bytes (512 B) copied, 0.00147225 s, 348 kB/s

dd if=kernel of=xv6.img seek=1 conv=notrunc

354+1 records in

354+1 records out

181388 bytes (181 kB) copied, 0.0597985 s, 3.0 MB/s

/usr/local/bin/qemu-system-i386 -nographic -drive

file=fs.img,index=1,media=disk,format=raw -drive

file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512

xv6...

cpu1: starting

cpu0: starting

sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32

bmap start 58

init: starting sh

$ ls

. 1 1 512

.. 1 1 512

README 2 2 2517

cat 2 3 14388

echo 2 4 13256

forktest 2 5 8096

grep 2 6 15944

init 2 7 14148

kill 2 8 13308

ln 2 9 13228

ls 2 10 16076

mkdir 2 11 13320

rm 2 12 13296

sh 2 13 24756

stressfs 2 14 14232

usertests 2 15 67164

wc 2 16 15084

zombie 2 17 12972

console 3 18 0

myFile 2 19 19

myfile 2 20 3

$ echo cse 660

Page 3: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

cse 660

$ cat README

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix

Version 6 (v6). xv6 loosely follows the structure and style of v6,

but is implemented for a modern x86-based multiprocessor using ANSI C.

ACKNOWLEDGMENTS

xv6 is inspired by John Lions's Commentary on UNIX 6th Edition (Peer

to Peer Communications; ISBN: 1-57398-013-7; 1st edition (June 14,

2000)). See also http://pdos.csail.mit.edu/6.828/2016/xv6.html, which

provides pointers to on-line resources for v6.

xv6 borrows code from the following sources:

JOS (asm.h, elf.h, mmu.h, bootasm.S, ide.c, console.c, and others)

Plan 9 (entryother.S, mp.h, mp.c, lapic.c)

FreeBSD (ioapic.c)

NetBSD (console.c)

The following people have made contributions: Russ Cox (context switching,

locking), Cliff Frey (MP), Xiao Yu (MP), Nickolai Zeldovich, and Austin

Clements.

We are also grateful for the bug reports and patches contributed by Silas

Boyd-Wickizer, Cody Cutler, Mike CAT, Nelson Elhage, Nathaniel Filardo,

Peter

Froehlich, Yakir Goaron, Shivam Handa, Bryan Henry, Jim Huang, Anders

Kaseorg,

kehao95, Wolfgang Keller, Eddie Kohler, Imbar Marinescu, Yandong Mao,

Hitoshi

Mitake, Carmi Merimovich, Joel Nider, Greg Price, Ayan Shafqat, Eldar

Sehayek,

Yongming Shen, Cam Tenny, Rafael Ubal, Warren Toomey, Stephen Tu, Pablo

Ventura,

Xi Wang, Keiichi Watanabe, Nicolas Wolovick, Jindong Zhang, and Zou Chang

Wei.

The code in the files that constitute xv6 is

Copyright 2006-2016 Frans Kaashoek, Robert Morris, and Russ Cox.

ERROR REPORTS

If you spot errors or have suggestions for improvement, please send email

to

Frans Kaashoek and Robert Morris (kaashoek,[email protected]). If you

have

suggestions for improvements, please keep in mind that the main purpose of

xv6

is as a teaching operating system for MIT's 6.828. For example, we are in

particular interested in simplifications and clarifications, instead of

suggestions for new systems calls, more portability, etc.

BUILDING AND RUNNING XV6

Page 4: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

To build xv6 on an x86 ELF machine (like Linux or FreeBSD), run "make".

On non-x86 or non-ELF machines (like OS X, even on x86), you will

need to install a cross-compiler gcc suite capable of producing x86 ELF

binaries. See http://pdos.csail.mit.edu/6.828/2016/tools.html.

Then run "make TOOLPREFIX=i386-jos-elf-".

To run xv6, install the QEMU PC simulators. To run in QEMU, run "make

qemu".

To create a typeset version of the code, run "make xv6.pdf". This

requires the "mpage" utility. See http://www.mesa.nl/pub/mpage/.

$ grep os README

Version 6 (v6). xv6 loosely follows the structure and style of v6,

2000)). See also http://pdos.csail.mit.edu/6.828/2016/xv6.html, which

kehao95, Wolfgang Keller, Eddie Kohler, Imbar Marinescu, Yandong Mao,

Hitoshi

suggestions for improvements, please keep in mind that the main purpose of

xv6

need to install a cross-compiler gcc suite capable of producing x86 ELF

binaries. See http://pdos.csail.mit.edu/6.828/2016/tools.html.

Then run "make TOOLPREFIX=i386-jos-elf-".

$ cat README | grep os | wc

7 59 473

$ echo cse 660 lab report > myFile

$ cat myFile

cse 660 lab report

Learning and Observations: Ran various commands like ls, echo, cat, grep in Xv6. All commands seems to work same as basic linux commands. =================================================================================== Answer a) Debugging GDB [root@localhost lab2]# make qemu-nox-gdb

dd if=/dev/zero of=xv6.img count=10000

10000+0 records in

10000+0 records out

5120000 bytes (5.1 MB) copied, 0.0643424 s, 79.6 MB/s

dd if=bootblock of=xv6.img conv=notrunc

1+0 records in

1+0 records out

512 bytes (512 B) copied, 0.00131342 s, 390 kB/s

dd if=kernel of=xv6.img seek=1 conv=notrunc

354+1 records in

354+1 records out

181388 bytes (181 kB) copied, 0.0270476 s, 6.7 MB/s

sed "s/localhost:1234/localhost:25000/" < .gdbinit.tmpl > .gdbinit

Page 5: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

*** Now run 'gdb'.

/usr/local/bin/qemu-system-i386 -nographic -drive

file=fs.img,index=1,media=disk,format=raw -drive

file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 -S -gdb

tcp::25000

============================================================================== Remote to XV6 [root@localhost lab2]# gdb

GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later

<http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. Type "show copying"

and "show warranty" for details.

This GDB was configured as "x86_64-redhat-linux-gnu".

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

warning: File "/root/Documents/lab2/.gdbinit" auto-loading has been

declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-

load:/usr/bin/mono-gdb.py".

To enable execution of this file add

add-auto-load-safe-path /root/Documents/lab2/.gdbinit

line to your configuration file "/root/.gdbinit".

To completely disable this security protection add

set auto-load safe-path /

line to your configuration file "/root/.gdbinit".

For more information about this security protection see the

"Auto-loading safe path" section in the GDB manual. E.g., run from the

shell:

info "(gdb)Auto-loading safe path"

(gdb) target remote : 25000

Remote debugging using : 25000

0x0000fff0 in ?? ()

(gdb) file kernel

A program is being debugged already.

Are you sure you want to change the file? (y or n) y

Reading symbols from /root/Documents/lab2/kernel...done.

(gdb) break swtch

Breakpoint 1 at 0x8010456b: file swtch.S, line 10.

(gdb) continue

Continuing.

Breakpoint 1, swtch () at swtch.S:10

10 movl 4(%esp), %eax

(gdb) step

11 movl 8(%esp), %edx

(gdb) step

14 pushl %ebp

(gdb) step

swtch () at swtch.S:15

Page 6: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

15 pushl %ebx

(gdb) step

swtch () at swtch.S:16

16 pushl %esi

(gdb) step

swtch () at swtch.S:17

17 pushl %edi

(gdb) step

swtch () at swtch.S:20

20 movl %esp, (%eax)

(gdb) step

21 movl %edx, %esp

(gdb) step

swtch () at swtch.S:24

24 popl %edi

(gdb) step

swtch () at swtch.S:25

25 popl %esi

(gdb) step

swtch () at swtch.S:26

26 popl %ebx

(gdb) step

swtch () at swtch.S:27

27 popl %ebp

(gdb) step

swtch () at swtch.S:28

28 ret

(gdb) step

forkret () at proc.c:351

351 {

(gdb) step

forkret () at proc.c:354

354 release(&ptable.lock);

(gdb) step

release (lk=<error reading variable: can't compute CFA for this frame>,

lk@entry=0x80112da0 <ptable>) at spinlock.c:48

48 {

(gdb) step

49 if(!holding(lk))

(gdb) step

holding (lock=0x80112da0 <ptable>) at spinlock.c:92

92 return lock->locked && lock->cpu == cpu;

(gdb) step

release (lk=<error reading variable: can't compute CFA for this frame>,

lk@entry=0x80112da0 <ptable>) at spinlock.c:52

52 lk->pcs[0] = 0;

(gdb) step

53 lk->cpu = 0;

(gdb) continue

Continuing.

Breakpoint 1, swtch () at swtch.S:10

10 movl 4(%esp), %eax

(gdb) clear

Page 7: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

Deleted breakpoint 1

(gdb) break exec

Breakpoint 2 at 0x801009b0: file exec.c, line 12.

(gdb) continue

Continuing.

[New Thread 2]

[Switching to Thread 2]

Breakpoint 1, exec (path=0x1c "/init", argv=argv@entry=0x8dfffeb0) at

exec.c:12

12 {

(gdb) step

21 begin_op();

(gdb) continue

Continuing.

Ran the following command in the Xv6 main terminal init: starting sh

$ ls -l

The Breakpoint was hit at the other terminal Breakpoint 1, exec (path=0x1940 "ls", argv=argv@entry=0x8dfbeeb0) at

exec.c:12

12 {

(gdb) step

21 begin_op();

(gdb) print argv[0]

$1 = 0x1940 "ls"

(gdb) print argv[1]

$2 = 0x1943 "-l"

(gdb) print argv[2]

$3 = 0x0

Ran Backtrace command

(gdb) backtrace

#0 exec (path=0x1940 "ls", argv=argv@entry=0x8dfbeeb0) at exec.c:21

#1 0x801051d3 in sys_exec () at sysfile.c:418

#2 0x80104739 in syscall () at syscall.c:133

#3 0x801056c1 in trap (tf=0x8dfbefb4) at trap.c:43

#4 0x801054aa in alltraps () at trapasm.S:23

#5 0x8dfbefb4 in ?? ()

Backtrace stopped: previous frame inner to this frame (corrupt stack?)

(gdb) up

#1 0x801051d3 in sys_exec () at sysfile.c:418

418 return exec(path, argv);

(gdb) list

413 break;

414 }

415 if(fetchstr(uarg, &argv[i]) < 0)

416 return -1;

417 }

418 return exec(path, argv);

Page 8: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

419 }

420

421 int

422 sys_pipe(void)

Learning and Observations: Learned how to run Xv6 in debug mode. Ran various commands to debug and to put breakpoints for debugging. Examined context switching by putting breakpoint on swtch using break swtch command. Ran continue and step commands to step through the context switching functions. Learned how to debug input command from the terminal such as ls -l Also learned how to apply patch to the Xv6 file and updating qemu path in Makefile in order to run Xv6 with Qemu. Difficulties encountered I was getting following error while using break exec Breakpoint 2, exec (

path=<error reading variable: can't compute CFA for this frame>,

argv=<error reading variable: can't compute CFA for this frame>,

argv@entry=0x8dfffeb0) at exec.c:12

Solution: Applied following patch to existing Makefile CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -

ggdb -m32 -Werror -fno-omit-frame-pointer -gdwarf-2

Answer b)

Examined and debugged 'wait' function in proc.c wait function does the following Waits for a child process to exit and return its pid Return -1 if this process has no children.

Applied breakpoints in proc.c

(gdb) break wait

Breakpoint 7 at 0x80103d90: file proc.c, line 232.

Execute echo command in the Xv6 main terminal $ echo lab2

It hits the breakpoint at line 7 Breakpoint 7, wait () at proc.c:232

232 {

Applied more breakpoints in the same wait function

(gdb) break 246

Breakpoint 8 at 0x80103e00: file proc.c, line 246.

(gdb) break 254

Page 9: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

Breakpoint 9 at 0x80103e3d: file proc.c, line 254.

(gdb) break 262

Breakpoint 10 at 0x80103e52: file proc.c, line 262.

(gdb) break 267

Breakpoint 11 at 0x80103deb: file proc.c, line 267.

Stepping through the function (gdb) step

236 acquire(&ptable.lock);

(gdb) step

acquire (lk=lk@entry=0x80114ce0 <tickslock>) at spinlock.c:27

27 pushcli(); // disable interrupts to avoid deadlock.

(gdb) continue

Continuing.

Breakpoint 11, wait () at proc.c:267

267 sleep(proc, &ptable.lock); //DOC: wait-sleep

(gdb) continue

Continuing.

It switches to thread 2 and execute echo command in the Xv6 main terminal $ echo lab2

lab2

In the other terminal breakpoint is hit [Switching to Thread 2]

Breakpoint 8, wait () at proc.c:246

246 pid = p->pid;

(gdb) continue

Continuing.

Breakpoint 9, wait () at proc.c:254

254 p->state = UNUSED;

(gdb) step

255 release(&ptable.lock);

(gdb) next

269 }

(gdb) next

256 return pid;

(gdb) continue

Continuing.

Finally wait function returns the pid for the child process. Answer C) Disassemble the kernel in i386 While running in debug mode, following commands were executed (gdb) set disassembly-flavor intel

(gdb) disass

Dump of assembler code for function acquire:

0x801041b0 <+0>: push ebp

Page 10: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

0x801041b1 <+1>: mov ebp,esp

0x801041b3 <+3>: sub esp,0x18

0x801041b6 <+6>: pushf

0x801041b7 <+7>: pop ecx

0x801041b8 <+8>: cli

0x801041b9 <+9>: mov eax,gs:0x0

0x801041bf <+15>: mov edx,DWORD PTR [eax+0xac]

0x801041c5 <+21>: test edx,edx

0x801041c7 <+23>: jne 0x801041d5 <acquire+37>

0x801041c9 <+25>: and ecx,0x200

0x801041cf <+31>: mov DWORD PTR [eax+0xb0],ecx

0x801041d5 <+37>: add edx,0x1

0x801041d8 <+40>: mov DWORD PTR [eax+0xac],edx

0x801041de <+46>: mov edx,DWORD PTR [ebp+0x8]

0x801041e1 <+49>: mov ecx,DWORD PTR [edx]

0x801041e3 <+51>: test ecx,ecx

0x801041e5 <+53>: je 0x801041ec <acquire+60>

0x801041e7 <+55>: cmp eax,DWORD PTR [edx+0x8]

0x801041ea <+58>: je 0x80104228 <acquire+120>

0x801041ec <+60>: mov ecx,0x1

0x801041f1 <+65>: jmp 0x801041fb <acquire+75>

---Type <return> to continue, or q <return> to quit---return

0x801041f3 <+67>: nop

0x801041f4 <+68>: lea esi,[esi+eiz*1+0x0]

=> 0x801041f8 <+72>: mov edx,DWORD PTR [ebp+0x8]

0x801041fb <+75>: mov eax,ecx

0x801041fd <+77>: lock xchg DWORD PTR [edx],eax

0x80104200 <+80>: test eax,eax

0x80104202 <+82>: jne 0x801041f8 <acquire+72>

0x80104204 <+84>: mfence

0x80104207 <+87>: mov eax,DWORD PTR [ebp+0x8]

0x8010420a <+90>: mov edx,DWORD PTR gs:0x0

0x80104211 <+97>: add eax,0xc

0x80104214 <+100>: mov DWORD PTR [eax-0x4],edx

0x80104217 <+103>: mov DWORD PTR [esp+0x4],eax

0x8010421b <+107>: lea eax,[ebp+0x8]

0x8010421e <+110>: mov DWORD PTR [esp],eax

0x80104221 <+113>: call 0x80104150 <getcallerpcs>

0x80104226 <+118>: leave

0x80104227 <+119>: ret

0x80104228 <+120>: mov DWORD PTR [esp],0x80107343

0x8010422f <+127>: call 0x80100360 <panic>

Answer d) Implementation of cp command to copy one file to two others /*

* copy command, cp for xv6 which copies one file to two other files

*/

#include "types.h"

#include "stat.h"

#include "user.h"

Page 11: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

#include "fcntl.h"

char buf[512];

void copy(char *file1, char *file2){

int fd0, fd1, n;

// Validation for opening of files

if((fd0 = open(file1, O_RDONLY)) < 0){

printf(1, "cp: cannot open %s\n", file1);

exit();

}

if((fd1 = open(file2, O_CREATE|O_RDWR)) < 0){

printf(1, "cp: cannot open %s\n", file2);

exit();

}

// Read file1 and write it to file2

while((n = read(fd0, buf, sizeof(buf))) > 0){

write(fd1, buf, n);

}

close(fd0);

close(fd1);

}

int

main(int argc, char *argv[])

{

// Check for number of parameters

if(argc <= 3){

printf(1, "Need 3 arguments!\n");

exit();

}

//Call copy function twice to copy from first file to other files

copy(argv[1], argv[2]);

copy(argv[1], argv[3]);

exit();

}

Testing and Execution a) Ran ls command. Output shows that cp has been added to Xv6

$ ls

. 1 1 512

.. 1 1 512

README 2 2 2517

cat 2 3 15504

echo 2 4 14288

forktest 2 5 8956

grep 2 6 17344

init 2 7 15196

Page 12: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

kill 2 8 14344

ln 2 9 14264

ls 2 10 17304

mkdir 2 11 14352

rm 2 12 14328

sh 2 13 27168

stressfs 2 14 15284

usertests 2 15 71080

wc 2 16 16200

cp 2 17 15612

zombie 2 18 14004

console 3 19 0

b) Ran cp command with no parameters

$ cp

Need 3 arguments!

c) Ran cp command with only one parameter

$ cp README

Need 3 arguments!

d) Ran cp with valid parameters

$ cp README myFile1 myFile2

e) Ran ls command to see whether files have been added. Output show files have been added with exact same size (in bytes) as of README.

$ ls

. 1 1 512

.. 1 1 512

README 2 2 2517

cat 2 3 15504

echo 2 4 14288

forktest 2 5 8956

grep 2 6 17344

init 2 7 15196

kill 2 8 14344

ln 2 9 14264

ls 2 10 17304

mkdir 2 11 14352

rm 2 12 14328

sh 2 13 27168

stressfs 2 14 15284

usertests 2 15 71080

wc 2 16 16200

cp 2 17 15612

zombie 2 18 14004

console 3 19 0

myFile1 2 20 2517

myFile2 2 21 2517

Page 13: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

f) Ran cat command for myFile1 and myFile2 to test the content of the files. Output shows that files have been successfully copied from README. $ cat myFile1

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix

Version 6 (v6). xv6 loosely follows the structure and style of v6,

but is implemented for a modern x86-based multiprocessor using ANSI C.

ACKNOWLEDGMENTS

xv6 is inspired by John Lions's Commentary on UNIX 6th Edition (Peer

to Peer Communications; ISBN: 1-57398-013-7; 1st edition (June 14,

2000)). See also http://pdos.csail.mit.edu/6.828/2016/xv6.html, which

provides pointers to on-line resources for v6.

xv6 borrows code from the following sources:

JOS (asm.h, elf.h, mmu.h, bootasm.S, ide.c, console.c, and others)

Plan 9 (entryother.S, mp.h, mp.c, lapic.c)

FreeBSD (ioapic.c)

NetBSD (console.c)

The following people have made contributions: Russ Cox (context switching,

locking), Cliff Frey (MP), Xiao Yu (MP), Nickolai Zeldovich, and Austin

Clements.

We are also grateful for the bug reports and patches contributed by Silas

Boyd-Wickizer, Cody Cutler, Mike CAT, Nelson Elhage, Nathaniel Filardo,

Peter

Froehlich, Yakir Goaron, Shivam Handa, Bryan Henry, Jim Huang, Anders

Kaseorg,

kehao95, Wolfgang Keller, Eddie Kohler, Imbar Marinescu, Yandong Mao,

Hitoshi

Mitake, Carmi Merimovich, Joel Nider, Greg Price, Ayan Shafqat, Eldar

Sehayek,

Yongming Shen, Cam Tenny, Rafael Ubal, Warren Toomey, Stephen Tu, Pablo

Ventura,

Xi Wang, Keiichi Watanabe, Nicolas Wolovick, Jindong Zhang, and Zou Chang

Wei.

The code in the files that constitute xv6 is

Copyright 2006-2016 Frans Kaashoek, Robert Morris, and Russ Cox.

ERROR REPORTS

If you spot errors or have suggestions for improvement, please send email

to

Frans Kaashoek and Robert Morris (kaashoek,[email protected]). If you

have

suggestions for improvements, please keep in mind that the main purpose of

xv6

is as a teaching operating system for MIT's 6.828. For example, we are in

particular interested in simplifications and clarifications, instead of

suggestions for new systems calls, more portability, etc.

Page 14: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

BUILDING AND RUNNING XV6

To build xv6 on an x86 ELF machine (like Linux or FreeBSD), run "make".

On non-x86 or non-ELF machines (like OS X, even on x86), you will

need to install a cross-compiler gcc suite capable of producing x86 ELF

binaries. See http://pdos.csail.mit.edu/6.828/2016/tools.html.

Then run "make TOOLPREFIX=i386-jos-elf-".

To run xv6, install the QEMU PC simulators. To run in QEMU, run "make

qemu".

To create a typeset version of the code, run "make xv6.pdf". This

requires the "mpage" utility. See http://www.mesa.nl/pub/mpage/.

$ cat myFile2

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix

Version 6 (v6). xv6 loosely follows the structure and style of v6,

but is implemented for a modern x86-based multiprocessor using ANSI C.

ACKNOWLEDGMENTS

xv6 is inspired by John Lions's Commentary on UNIX 6th Edition (Peer

to Peer Communications; ISBN: 1-57398-013-7; 1st edition (June 14,

2000)). See also http://pdos.csail.mit.edu/6.828/2016/xv6.html, which

provides pointers to on-line resources for v6.

xv6 borrows code from the following sources:

JOS (asm.h, elf.h, mmu.h, bootasm.S, ide.c, console.c, and others)

Plan 9 (entryother.S, mp.h, mp.c, lapic.c)

FreeBSD (ioapic.c)

NetBSD (console.c)

The following people have made contributions: Russ Cox (context switching,

locking), Cliff Frey (MP), Xiao Yu (MP), Nickolai Zeldovich, and Austin

Clements.

We are also grateful for the bug reports and patches contributed by Silas

Boyd-Wickizer, Cody Cutler, Mike CAT, Nelson Elhage, Nathaniel Filardo,

Peter

Froehlich, Yakir Goaron, Shivam Handa, Bryan Henry, Jim Huang, Anders

Kaseorg,

kehao95, Wolfgang Keller, Eddie Kohler, Imbar Marinescu, Yandong Mao,

Hitoshi

Mitake, Carmi Merimovich, Joel Nider, Greg Price, Ayan Shafqat, Eldar

Sehayek,

Yongming Shen, Cam Tenny, Rafael Ubal, Warren Toomey, Stephen Tu, Pablo

Ventura,

Xi Wang, Keiichi Watanabe, Nicolas Wolovick, Jindong Zhang, and Zou Chang

Wei.

The code in the files that constitute xv6 is

Copyright 2006-2016 Frans Kaashoek, Robert Morris, and Russ Cox.

Page 15: LAB 2 CSE 660 Submitted By: Arumugam Thendramil Pavaicse.csusb.edu/tongyu/studentwork/cs660/labs/lab2_dir/... · 2017. 4. 12. · $ cat README | grep os | wc 7 59 473 $ echo cse 660

ERROR REPORTS

If you spot errors or have suggestions for improvement, please send email

to

Frans Kaashoek and Robert Morris (kaashoek,[email protected]). If you

have

suggestions for improvements, please keep in mind that the main purpose of

xv6

is as a teaching operating system for MIT's 6.828. For example, we are in

particular interested in simplifications and clarifications, instead of

suggestions for new systems calls, more portability, etc.

BUILDING AND RUNNING XV6

To build xv6 on an x86 ELF machine (like Linux or FreeBSD), run "make".

On non-x86 or non-ELF machines (like OS X, even on x86), you will

need to install a cross-compiler gcc suite capable of producing x86 ELF

binaries. See http://pdos.csail.mit.edu/6.828/2016/tools.html.

Then run "make TOOLPREFIX=i386-jos-elf-".

To run xv6, install the QEMU PC simulators. To run in QEMU, run "make

qemu".

To create a typeset version of the code, run "make xv6.pdf". This

requires the "mpage" utility. See http://www.mesa.nl/pub/mpage/.

Learnings and Observations: a) Learned various functions for reading/writing files (e.g. read(), open() and write()) b) Learned how to implement a new command in the Xv6. All the required parts for this lab were successfully completed.