system. You will finish the function definitions in src/vm_schedule.c to implement a
process scheduler for this virtual machine to let it know which is the best one to pick next.
C Programming Question
Read chapters 4 and 5 in the OSTEP book.
Write a simple shell, which is a program that waits for you to type a command, and once you type it, runs that command (that program).
Your shell should have a “prompt”, which is a symbol or message that indicates it’s ready to receive commands. The xv6 shell has “$” and the delenn shell has “[[email protected]] $” or similar. Choose your own prompt.
Make sure your shell can run programs with or without arguments, like “ls” or “cat README” and so on.
Print an error message if the command the user types cannot be executed.
Shells also often have some builtin commands that are not programs (they don’t cause a fork/exec). Support the following builtin commands:
help – shows a simple message about how to use your shell
pid – shows the shell’s process id
cd – changes shell’s current directory
pwd – shows the shell’s current directory
Avoid all zombies.
Turn in your .c file. You can name it whatever you want.
Hints:
Use the strsplit() function we created in class to break the user input into argv array.
When creating argv (probably with strsplit), make sure you add another slot at the end that you fill with a 0 (null). This is what exec() expects.
To support “cd” (change directory), first, don’t do a fork/exec since cd needs to change the directory of the shell process; instead, run the function chdir(new_dir_name) which is defined by xv6. This will change the directory the shell is running in, so if the shell tries to open/save files, run programs, etc., it will look in this “current working directory” to do so.
To support “pwd” (print working directory), keep track of the working directory (from the “cd” command) in your own code. The first working directory will be “/” when the shell starts. There is no way to get the name of the current working directory from xv6.
Outline of code:
1- Start a loop (we are going to loop forever so users can type commands over and over again).
(1) Get the input
2- Check some cases that handled inside the shell (no forking, “built-in” commands):
(1) change directory
(2) print directory
(3) help
(4) get process id
3- Otherwise (not “built-in” command):
(1)Split the command into argv array
(2)Fork
(3)Child runs exec
(4)Parent waits
———————————————————————————————————-
I will upload two file :
link https://pages.cs.wisc.edu/~remzi/OSTEP/ as Assignment said for Read chapters 4 and 5 in the OSTEP book. as
mysh.c this file professor solved part of the assignment maybe this file will help u and I prefer to use professor file and solve rest of the assignment
C Programming Question
Programming Assignment Help Read chapters 4 and 5 in the OSTEP book.
Write a simple shell, which is a program that waits for you to type a command, and once you type it, runs that command (that program).
Your shell should have a “prompt”, which is a symbol or message that indicates it’s ready to receive commands. The xv6 shell has “$” and the delenn shell has “[[email protected]] $” or similar. Choose your own prompt.
Make sure your shell can run programs with or without arguments, like “ls” or “cat README” and so on.
Print an error message if the command the user types cannot be executed.
Shells also often have some builtin commands that are not programs (they don’t cause a fork/exec). Support the following builtin commands:
help – shows a simple message about how to use your shell
pid – shows the shell’s process id
cd – changes shell’s current directory
pwd – shows the shell’s current directory
Avoid all zombies.
Turn in your .c file. You can name it whatever you want.
Hints:
Use the strsplit() function we created in class to break the user input into argv array.
When creating argv (probably with strsplit), make sure you add another slot at the end that you fill with a 0 (null). This is what exec() expects.
To support “cd” (change directory), first, don’t do a fork/exec since cd needs to change the directory of the shell process; instead, run the function chdir(new_dir_name) which is defined by xv6. This will change the directory the shell is running in, so if the shell tries to open/save files, run programs, etc., it will look in this “current working directory” to do so.
To support “pwd” (print working directory), keep track of the working directory (from the “cd” command) in your own code. The first working directory will be “/” when the shell starts. There is no way to get the name of the current working directory from xv6.
Outline of code:
1- Start a loop (we are going to loop forever so users can type commands over and over again).
(1) Get the input
2- Check some cases that handled inside the shell (no forking, “built-in” commands):
(1) change directory
(2) print directory
(3) help
(4) get process id
3- Otherwise (not “built-in” command):
(1)Split the command into argv array
(2)Fork
(3)Child runs exec
(4)Parent waits
———————————————————————————————————-
I will upload two file :
link https://pages.cs.wisc.edu/~remzi/OSTEP/ as Assignment said for Read chapters 4 and 5 in the OSTEP book. as
mysh.c this file professor solved part of the assignment maybe this file will help u and I prefer to use professor file and solve rest of the assignment
C Programming Question
Read chapters 4 and 5 in the OSTEP book.
Write a simple shell, which is a program that waits for you to type a command, and once you type it, runs that command (that program).
Your shell should have a “prompt”, which is a symbol or message that indicates it’s ready to receive commands. The xv6 shell has “$” and the delenn shell has “[[email protected]] $” or similar. Choose your own prompt.
Make sure your shell can run programs with or without arguments, like “ls” or “cat README” and so on.
Print an error message if the command the user types cannot be executed.
Shells also often have some builtin commands that are not programs (they don’t cause a fork/exec). Support the following builtin commands:
help – shows a simple message about how to use your shell
pid – shows the shell’s process id
cd – changes shell’s current directory
pwd – shows the shell’s current directory
Avoid all zombies.
Turn in your .c file. You can name it whatever you want.
Hints:
Use the strsplit() function we created in class to break the user input into argv array.
When creating argv (probably with strsplit), make sure you add another slot at the end that you fill with a 0 (null). This is what exec() expects.
To support “cd” (change directory), first, don’t do a fork/exec since cd needs to change the directory of the shell process; instead, run the function chdir(new_dir_name) which is defined by xv6. This will change the directory the shell is running in, so if the shell tries to open/save files, run programs, etc., it will look in this “current working directory” to do so.
To support “pwd” (print working directory), keep track of the working directory (from the “cd” command) in your own code. The first working directory will be “/” when the shell starts. There is no way to get the name of the current working directory from xv6.
Outline of code:
1- Start a loop (we are going to loop forever so users can type commands over and over again).
(1) Get the input
2- Check some cases that handled inside the shell (no forking, “built-in” commands):
(1) change directory
(2) print directory
(3) help
(4) get process id
3- Otherwise (not “built-in” command):
(1)Split the command into argv array
(2)Fork
(3)Child runs exec
(4)Parent waits
———————————————————————————————————-
I will upload two file :
link https://pages.cs.wisc.edu/~remzi/OSTEP/ as Assignment said for Read chapters 4 and 5 in the OSTEP book. as
mysh.c this file professor solved part of the assignment maybe this file will help u and I prefer to use professor file and solve rest of the assignment