CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20...

23
Mike Cheng-Godinez 4/16/19 CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or it may not have ran. [[email protected]@jb358-17 lab3]$ vi test_exec.cpp [[email protected]@jb358-17 lab3]$ g++ test_exec.cpp -o test_exec [[email protected]@jb358-17 lab3]$ ./test_exec Running ps with execl Done! [[email protected]@jb358-17 lab3]$ //test_exec.cpp #include <iostream> #include <unistd.h> #include <sys/wait.h> using namespace std; int main(){ cout << "Running ps with execl\n"; execl( "ps", "ps", "-ax", 0 ); cout << "Done!\n"; return 0; }

Transcript of CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20...

Page 1: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

Mike Cheng-Godinez 4/16/19 CSE460-03 Lab3 - 20 points

1) Replacing a Process Image //I see that the command is not displayed or it may not have ran. [[email protected]@jb358-17 lab3]$ vi test_exec.cpp [[email protected]@jb358-17 lab3]$ g++ test_exec.cpp -o test_exec [[email protected]@jb358-17 lab3]$ ./test_exec Running ps with execl Done! [[email protected]@jb358-17 lab3]$ //test_exec.cpp #include <iostream> #include <unistd.h> #include <sys/wait.h> using namespace std; int main(){

cout << "Running ps with execl\n"; execl( "ps", "ps", "-ax", 0 ); cout << "Done!\n"; return 0;

}

Page 2: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

2) Duplicating a Process Image //I ran the progam 3 times in case there was some error, but it prints the last child onto the next //line since the parent process does not wait for its child process it finishes, but what I saw was //that the program displayed the messages of the parent and the child one after the other with 1 //sec delay in between their cout operation.

//I changed char* to string below and decided that I did not need to include the library since it //still ran fine //test_fork.cpp #include <sys/types.h> #include <unistd.h> #include <iostream>

Page 3: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

using namespace std; int main() { pid_t pid; //process id string message; int n; cout << "fork program starting\n"; pid = fork(); switch ( pid ) { case -1: cout << "Fork failure!\n"; return 1; case 0: message = "This is the child\n"; n = 5; break; default: message = "This is the parent\n"; n = 3; break; } for ( int i = 0; i < n; ++i ) { cout << message; sleep ( 1 ); } return 0; }

Page 4: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

3) Waiting for a Process //This program prints the messages parent and child from their respective processes with 1sec //delay and when the parent process is done it waits for its child process to finish cout its //message statements its, then when the child process ends, the parent process prints the PID //of its child that it has been waiting for to finish and its exit code.

//test_wait.cpp #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { pid_t pid; //process id string message;

Page 5: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

int n; int exit_code; cout << "fork program starting\n"; pid = fork(); switch ( pid ) { case -1: cout << "Fork failure!\n"; return 1; case 0: message = "This is the child\n"; n = 5; exit_code = 9; break; default: message = "This is the parent\n"; n = 3; exit_code = 0; break; } for ( int i = 0; i < n; ++i ) { cout << message; sleep ( 1 ); } //waiting for child to finish if ( pid != 0 ) { //parent int stat_val; pid_t child_pid; child_pid = wait ( &stat_val ); //wait for child cout << "Child finished: PID = " << child_pid << endl; if ( WIFEXITED ( stat_val ) ) cout << "child exited with code " << WEXITSTATUS ( stat_val ) << endl; else cout << "child terminated abnormally!" << endl; } exit ( exit_code ); }

Page 6: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

//child process prints out its parent id and grandparent id

//test_wait2.cpp #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { pid_t pid; //process id string message; int n; int exit_code; pid_t pid2; //pid2 = getpid(); //this works too cout << "fork program starting\n"; pid = fork();

Page 7: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

pid2 = getppid(); switch ( pid ) { case -1: cout << "Fork failure!\n"; return 1; case 0: message = "This is the child";

pid = fork(); n = 5;

if(pid == 0){ message = "This is grandchild"; n = 7;

} exit_code = 9; break; default: message = "This is the parent"; n = 3; exit_code = 0; break; } for ( int i = 0; i < n; ++i ) { cout << message << " id " << getpid() << endl; sleep ( 1 ); } if(pid == 0){//grandchild

cout << "I am child id " << getpid() << ", My parent is id " << getppid() << ", my grandparent is id " << pid2 << "\n"; } //waiting for child to finish if ( pid != 0 ) { //parent and grandparent int stat_val; pid_t child_pid; child_pid = wait ( &stat_val ); //wait for child cout << "Child finished: PID = " << child_pid << endl; if ( WIFEXITED ( stat_val ) ) cout << "child exited with code " << WEXITSTATUS ( stat_val ) << endl; else cout << "child terminated abnormally!" << endl; } exit ( exit_code ); }

Page 8: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

4) Signals //I saw that when ever I tried to ctrl + c the program would print out and Oops message and the //program would continue to run, because the program has a signal function that catches my //ctrl + c command and prints out the Oops message and the signal value of ctrl + c command.

//test_signal.cpp

Page 9: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

#include <signal.h> #include <unistd.h> #include <iostream> using namespace std; void func ( int sig ) { cout << "Oops! -- I got a signal " << sig << endl; } int main() { (void) signal ( SIGINT, func ); //catch terminal interrupts for ( int i = 0; i < 20; ++i ) { cout << "CSUSB CS 460 lab on signals" << endl; sleep ( 1 ); } return 0; } /* Sending Signals */ //I see that the alarm testing message and the message about it waiting for alarm to go off. //Because from what I see from the code, it creates a fork and the child process whats 5 //seconds to call the kill command that kills its parent and also sends the value SIGALRM that //the parent process is waiting to catch the kill command with its signal function that prevents its //termination and calling the ding function to print alarm went off, I noticed that this simulates an //alarm and does not use any actual alarm function, and then prints done at the end. [[email protected]@jb357-l1 lab3]$ ./test_alarm Alarm testing! Waiting for alarm to go off! Alarm has gone off Done! [[email protected]@jb357-l1 lab3]$ //test_alarm.cpp #include <signal.h> #include <unistd.h> #include <iostream> using namespace std;

Page 10: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

//simulates an alarm clock void ding ( int sig ) { cout << "Alarm has gone off " << endl; } //tell child process to wait for 5 seconds before sending //a SIGALRM signal to its parent. int main() { int pid; cout << "Alarm testing!" << endl; if ( ( pid = fork() ) == 0 ) { //child sleep ( 5 ); /*

Get parent process id, send SIGALARM signal to it. */ kill ( getppid(), SIGALRM ); return 1; } //parent process arranges to catch SIGALRM with a call //to signal and then waits for the inevitable. cout << "Waiting for alarm to go off!" << endl; (void) signal ( SIGALRM, ding ); pause(); //process suspended, waiting for signals to wake up cout << "Done!" << endl; return 1; } /* More Robust Signal Interface */ [[email protected]@jb357-l1 lab3]$ g++ test_signal2.cpp -o test_signal2 [[email protected]@jb357-l1 lab3]$ ./test_signal2 CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2

Page 11: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction ^COops! -- I got a signal 2 CSUSB CS 460 lab on sigaction CSUSB CS 460 lab on sigaction ^\Quit (core dumped) [[email protected]@jb357-l1 lab3]$ //test_signal2.cpp #include <signal.h> #include <unistd.h> #include <iostream> using namespace std; void func ( int sig ) { cout << "Oops! -- I got a signal " << sig << endl; } int main() {

Page 12: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

//(void) signal ( SIGINT, func ); //catch terminal interrupts struct sigaction new_action, old_action; sigemptyset(&old_action.sa_mask); sigemptyset(&new_action.sa_mask); new_action.sa_handler = func; while (1) { cout << "CSUSB CS 460 lab on sigaction" << endl; //sigaction(SIGINT, NULL, &old_action); sigaction(SIGINT, &new_action, &old_action); // if(old_action.sa_handler == SIG_IGN){ // //sigaction(SIGINT, &new_action, NULL); // cout << "check\n"; // } sleep ( 1 ); } return 0; }

5) Study of XV6 [[email protected]@jb357-l1 xv6]$ cp -r /pool/u/class/cs460/xv6/. . [[email protected]@jb357-l1 xv6]$ ls asm.h fcntl.h lapic.c pipe.c sleeplock.h traps.h bio.c file.c LICENSE printf.c spinlock.c TRICKS bootasm.S file.h ln.c printpcs spinlock.h types.h bootmain.c forktest.c log.c proc.c spinp uart.c buf.h fs.c ls.c proc.h stat.h ulib.c BUGS fs.h main.c pr.pl stressfs.c umalloc.c cat.c gdbutil Makefile README string.c user.h console.c grep.c memide.c rm.c swtch.S usertests.c cuth ide.c memlayout.h runoff symlink.patch usys.S date.h init.c mkdir.c runoff1 syscall.c vectors.pl defs.h initcode.S mkfs.c runoff.list syscall.h vm.c dot-bochsrc ioapic.c mmu.h runoff.spec sysfile.c wc.c echo.c kalloc.c mp.c sh.c sysproc.c x86.h elf.h kbd.c mp.h show1 toc.ftr zombie.c entryother.S kbd.h Notes sign.pl toc.hdr entry.S kernel.ld param.h sleep1.p trapasm.S exec.c kill.c picirq.c sleeplock.c trap.c [[email protected]@jb357-l1 xv6]$ make gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic -O -nostdinc -I. -c bootmain.c

Page 13: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic -nostdinc -I. -c bootasm.S ld -m elf_i386 -N -e start -Ttext 0x7C00 -o bootblock.o bootasm.o bootmain.o objdump -S bootblock.o > bootblock.asm objcopy -S -O binary -j .text bootblock.o bootblock ./sign.pl bootblock boot block is 451 bytes (max 510) gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o bio.o bio.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o console.o console.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o exec.o exec.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o file.o file.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o fs.o fs.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o ide.o ide.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o ioapic.o ioapic.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o kalloc.o kalloc.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o kbd.o kbd.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o lapic.o lapic.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o log.o log.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o main.o main.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o mp.o mp.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o picirq.o picirq.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o pipe.o pipe.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o proc.o proc.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o sleeplock.o sleeplock.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o spinlock.o spinlock.c

Page 14: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o string.o string.c gcc -m32 -gdwarf-2 -Wa,-divide -c -o swtch.o swtch.S gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o syscall.o syscall.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o sysfile.o sysfile.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o sysproc.o sysproc.c gcc -m32 -gdwarf-2 -Wa,-divide -c -o trapasm.o trapasm.S gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o trap.o trap.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o uart.o uart.c perl vectors.pl > vectors.S gcc -m32 -gdwarf-2 -Wa,-divide -c -o vectors.o vectors.S gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o vm.o vm.c gcc -m32 -gdwarf-2 -Wa,-divide -c -o entry.o entry.S gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -fno-pic -nostdinc -I. -c entryother.S ld -m elf_i386 -N -e start -Ttext 0x7000 -o bootblockother.o entryother.o objcopy -S -O binary -j .text bootblockother.o entryother objdump -S bootblockother.o > entryother.asm gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -nostdinc -I. -c initcode.S ld -m elf_i386 -N -e start -Ttext 0 -o initcode.out initcode.o objcopy -S -O binary initcode.out initcode objdump -S initcode.o > initcode.asm ld -m elf_i386 -T kernel.ld -o kernel entry.o bio.o console.o exec.o file.o fs.o ide.o ioapic.o kalloc.o kbd.o lapic.o log.o main.o mp.o picirq.o pipe.o proc.o sleeplock.o spinlock.o string.o swtch.o syscall.o sysfile.o sysproc.o trapasm.o trap.o uart.o vectors.o vm.o -b binary initcode entryother objdump -S kernel > kernel.asm objdump -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > kernel.sym gcc -Werror -Wall -o mkfs mkfs.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o ulib.o ulib.c gcc -m32 -gdwarf-2 -Wa,-divide -c -o usys.o usys.S gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o printf.o printf.c gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o umalloc.o umalloc.c

Page 15: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o cat.o cat.c ld -m elf_i386 -N -e main -Ttext 0 -o _cat cat.o ulib.o usys.o printf.o umalloc.o objdump -S _cat > cat.asm objdump -t _cat | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > cat.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o echo.o echo.c ld -m elf_i386 -N -e main -Ttext 0 -o _echo echo.o ulib.o usys.o printf.o umalloc.o objdump -S _echo > echo.asm objdump -t _echo | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > echo.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o forktest.o forktest.c # forktest has less library code linked in - needs to be small # in order to be able to max out the proc table. ld -m elf_i386 -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o objdump -S _forktest > forktest.asm gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o grep.o grep.c ld -m elf_i386 -N -e main -Ttext 0 -o _grep grep.o ulib.o usys.o printf.o umalloc.o objdump -S _grep > grep.asm objdump -t _grep | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > grep.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o init.o init.c ld -m elf_i386 -N -e main -Ttext 0 -o _init init.o ulib.o usys.o printf.o umalloc.o objdump -S _init > init.asm objdump -t _init | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > init.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o kill.o kill.c ld -m elf_i386 -N -e main -Ttext 0 -o _kill kill.o ulib.o usys.o printf.o umalloc.o objdump -S _kill > kill.asm objdump -t _kill | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > kill.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o ln.o ln.c ld -m elf_i386 -N -e main -Ttext 0 -o _ln ln.o ulib.o usys.o printf.o umalloc.o objdump -S _ln > ln.asm objdump -t _ln | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > ln.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o ls.o ls.c ld -m elf_i386 -N -e main -Ttext 0 -o _ls ls.o ulib.o usys.o printf.o umalloc.o objdump -S _ls > ls.asm objdump -t _ls | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > ls.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o mkdir.o mkdir.c

Page 16: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

ld -m elf_i386 -N -e main -Ttext 0 -o _mkdir mkdir.o ulib.o usys.o printf.o umalloc.o objdump -S _mkdir > mkdir.asm objdump -t _mkdir | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > mkdir.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o rm.o rm.c ld -m elf_i386 -N -e main -Ttext 0 -o _rm rm.o ulib.o usys.o printf.o umalloc.o objdump -S _rm > rm.asm objdump -t _rm | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > rm.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o sh.o sh.c ld -m elf_i386 -N -e main -Ttext 0 -o _sh sh.o ulib.o usys.o printf.o umalloc.o objdump -S _sh > sh.asm objdump -t _sh | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > sh.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o stressfs.o stressfs.c ld -m elf_i386 -N -e main -Ttext 0 -o _stressfs stressfs.o ulib.o usys.o printf.o umalloc.o objdump -S _stressfs > stressfs.asm objdump -t _stressfs | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > stressfs.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o usertests.o usertests.c ld -m elf_i386 -N -e main -Ttext 0 -o _usertests usertests.o ulib.o usys.o printf.o umalloc.o objdump -S _usertests > usertests.asm objdump -t _usertests | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > usertests.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o wc.o wc.c ld -m elf_i386 -N -e main -Ttext 0 -o _wc wc.o ulib.o usys.o printf.o umalloc.o objdump -S _wc > wc.asm objdump -t _wc | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > wc.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer -fno-stack-protector -c -o zombie.o zombie.c ld -m elf_i386 -N -e main -Ttext 0 -o _zombie zombie.o ulib.o usys.o printf.o umalloc.o objdump -S _zombie > zombie.asm objdump -t _zombie | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$/d' > zombie.sym ./mkfs fs.img README _cat _echo _forktest _grep _init _kill _ln _ls _mkdir _rm _sh _stressfs _usertests _wc _zombie nmeta 59 (boot, super, log blocks 30 inode blocks 26, bitmap blocks 1) blocks 941 total 1000 balloc: first 628 blocks have been allocated balloc: write bitmap block at sector 58 dd if=/dev/zero of=xv6.img count=10000 10000+0 records in 10000+0 records out 5120000 bytes (5.1 MB, 4.9 MiB) copied, 0.148882 s, 34.4 MB/s dd if=bootblock of=xv6.img conv=notrunc

Page 17: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

1+0 records in 1+0 records out 512 bytes copied, 0.00155562 s, 329 kB/s dd if=kernel of=xv6.img seek=1 conv=notrunc 395+1 records in 395+1 records out 202524 bytes (203 kB, 198 KiB) copied, 0.00451949 s, 44.8 MB/s [[email protected]@jb357-l1 xv6]$ //I was not able to get screenshot of before I ran “make qemu-nox” so this is a screenshot of //after I ran the command.

Page 18: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

// xv6 “ls” and “echo cse 460” commands

// xv6 “cat README” command

Page 19: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or
Page 20: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

// xv6 “grep os README” command

// xv6 “cat README | grep os | wc”, “echo cse 460 lab report > myFile”, and “$ cat myFile” //commands

Page 21: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

//”make qemu-nox-gdb” command and the before and after the gdb “continue” command

Page 22: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

//gdb debugger commands: “continue”, “file kernel”, “set disassembly-flavor intel” and “disass”

/*

I should have asked but what sample code comes from the gdb for this section? I only put screenshots

*/

Page 23: CSE460-03 Done! - CSUSBcse.csusb.edu/tongyu/studentwork/cs460/labs/lab3... · CSE460-03 Lab3 - 20 points 1) Replacing a Process Image //I see that the command is not displayed or

Points Earned: 20 I practiced: replacing a process image, duplicating a process image, waiting for a process, signals, and did the practice study of XV6, and modified each exercise according to the instructions.