Skip to content

ashutosh-147/CS111-lab1

Repository files navigation

TODO: Lab1c
Fix subshell so it forks and records its own time
2+ test cases
tests in general

Ashutosh Shiledar (304142693)
Nicholas Chung (404252775)

Lab 1a :
Our current implementation of the shell produces warnings regarding the 'prepare_profiling' and 'execute_command' functions in the 'execute_command.c' file because those functions correspond to lab 1b and 1c.
Beyond warnings (which we suppress by voiding the option 'Werror' in Makefile), there are no known limitations.

Lab 1b :
Currently, we get two warnings during compilation. The first is for an unused parameter in prepare_profiling, a function that will be implemented in part c. The second is for an unused parameter
in execute_command, which will be later used in the implementation of part c.

We started the design problem for this project which includes implementing the -v (verbose) and -x (xtrace) flags. Using the -v simply prints out the contents of the script before it executes any
commands. The -x option prints out simple commands (preceded by a '+') before it executes it. We also added a -s option that allows you to 'step' through the code, similar to gdb and other
debuggers. When this option is selected, it prints out the command, just like in the -x option, but then waits for the user to press the enter key to continue with the execution. This allows the user
to see what is going to get executed before the command is run.

Lab 1c:

Beyond the constraints as required in the specs, there are no known limitations. 

For the first column, we used CLOCK_REALTIME as required by the specifications. For the execution time, we used CLOCK_MONOTONIC to prevent commands with appropriate priveleges to be able to alter the value of the execution time. The CPU times are calculated using getrusage(RUSAGE_CHILDREN,...) because all execvp commands are run in child processes.

The first column does not have to be in non-decreasing order because CLOCK_REALTIME can be changed with appropriate priveleges, including the start and end of daylight savings. For example, at the end of daylight savings, the clock should jump from 1:59am to 1:00am.
The sum of the third (user CPU time) and fourth (system CPU time) columns can be greater than the second (execution time) column when multi-threading. When multi-threading, each process can use multiple threads to accelerate performance. However, the CPU time will be the sum of the individual thread times, whereas the execution time of the process will decrease. 
None of the columns should be negative. The second column is calculated from the difference of the end and start time of the process; but, we use CLOCK_MONOTONIC, so the clock times must always be non-negative. The third and fourth column times are gathered from getrusage(RUSAGE_CHILDREN, struct rusage * usage) and will always be non-negative.
We did not test our shell for interleaving because interleaving occurs only when the shell is parallelized. However, this lab does not require parallelism (design problem). 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published