CS370 Assignment 1: Shellminator! Fall 2026 Answered – C Shell Simulator & Virtual File System

$75.00

This downloadable ZIP file covers a C programming shell simulation project featuring an in-memory virtual filesystem, simulated UNIX commands, command history, process management, pipes, and output redirection. The resource addresses shell command execution, process tracing, built-in commands, error handling, and C90 programming restrictions.

Original Work ?

Download Details:

  • Name: CS370-hw01-ciqvuh.zip
  • Type: zip
  • Size: 998.14 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

Rate this product

CS370 Assignment 1: Shellminator! Fall 2026 focuses on building a simulated command-line shell in C without using real operating-system process or filesystem calls. Students implement virtual filesystem commands, command history, simulated process management, in-memory pipes, and output redirection while following C90 compilation requirements and strict function specifications.

Assignment Description

Ah yes, writing your own shell — because installing a pre-made one was simply too mainstream and lacking
in segmentation faults. . . This assignment is a teaching shell that models operating-system concepts without
calling fork(), exec(), wait(), pipe(), chdir(), getcwd(), open(), dup(), or any other POSIX process/filesystem
system call. In fact, the virtual filesystem is created in memory when the program starts. The provided
notes.txt, names.txt, project.txt, and log.txt files are copies of the text embedded in that virtual filesystem;
the shell does not open those host files!
Why use the command line?
For most users of modern computers, interacting with a computer means using a graphical interface controlled
by a mouse or touchpad. We click programs to launch them, click or drag files to open or manipulate them,
select menu items to perform specific operations, and click buttons to respond to prompts.
This graphical user interface (GUI) approach has several important advantages. It is relatively easy to learn
and use, and it makes computer operations easy to visualize through familiar physical metaphors such as
documents, folders, windows, and menus. However, GUIs also come with a few drawbacks — brownie points
for anyone who can name them in class!. . .
The command line provides an alternative way to interact with a computer. Instead of relying on graphical
controls, users enter textual commands to run programs with specific configurations and apply them to
selected data. Unfortunately, the command-line approach also has some disadvantages:
• It has a relatively steep learning curve.
• There are many commands and configuration options, some of which are not easy to remember.
• Many commands are designed primarily for working with text files.
Despite these drawbacks, the command line offers several significant advantages:
• Individual operations can be easily combined to create new and useful workflows.
• Complex commands can be constructed from multiple simple components.
• Commands can be saved and reused, modified, or automated later.
• Commands can be parameterized to make them useful in a wider range of situations.
• Once users become familiar with the command line, many tasks can be performed much more quickly
than through a graphical interface.
1
Use Case
Let us take a look at the following example.
Suppose you need to solve the following problem: read a text file, identify the n most frequently used words,
and print a sorted list of those words along with their frequencies. How could you approach this task?
1. Find an existing program
The first option is to look for a program that already solves the problem. For common tasks, this may
work well. However, for more specialized problems, an existing solution may be difficult or impossible
to find. You might instead have to use an environment such as Excel and build a solution yourself.
2. Write a specialized program
Another option is to write a program specifically for the task. Donald Knuth, for example, wrote a
ten-page Pascal program to solve this problem. The program was designed as an example of literate
programming, with the goal of making the code understandable and readable by both humans and
computers.
3. Use the command line A third option is to solve the problem directly from the command line. Doug
McIlroy demonstrated how the task could be completed quickly with this short sequence of commands:
tr -cs A-Za-z ’\n’ |
tr A-Z a-z |
sort |
uniq -c |
sort -rn |
sed ${1}q
Each command in this chain performs one simple operation on its input. McIlroy’s script configures
these programs using command-line options and connects them through a pipeline, allowing their
individual operations to be combined into a more complex task.
All three approaches are useful and valid. However, the third approach demonstrates one of the
command line’s greatest strengths: the ability to combine simple, focused tools into powerful solutions.
When programs are designed to do one thing well, they can be connected and reused in countless
combinations, giving users a large and flexible collection of tools for solving a wide variety of problems.
Simshell — The Shell
The handout contains comments for all functions, detailing both the pre-written code and the components
you need to implement, with this section focusing exclusively on your assigned tasks. Because we are
simulating a shell, you must strictly avoid using any function libraries that trigger system calls!
Now, a normal shell works with the files and directories stored on your computer. For this assignment, we do
not want to modify or depend upon the computer’s real filesystem. Instead, the program contains a Virtual
File System, or VFS.
The Virtual File System is simply a collection of structures and arrays that represent directories and files in
memory. For example, the simulated filesystem might contain:
/
+— home
| +— student
| +— notes.txt
| +— names.txt
| \— docs
| +— project.txt
|
+— tmp
2
\— log.txt
These files and directories are not the files and directories on your computer. They exist only inside the
simulated shell. For example, when the user enters:
ls
the program examines the Virtual File System and displays the files belonging to the simulated current
directory. Similarly,
cat notes.txt
displays the contents stored in the simulated notes.txt file. The command:
cd docs
changes the shell’s simulated current directory. It does not change the current directory of the real program.
Simulated Processes
Later in the course, we will study processes in considerably more detail. For now, you only need a simple
idea of what a process represents in this assignment. A process represents a command that is being executed.
For example, if the shell executes:
ls
we can imagine that the shell creates a temporary process whose job is to execute the simulated ls command.
A Process structure stores a small amount of information about that simulated command. It may contain
information such as:
• process ID
• parent process ID
• command name
• current directory
• process state
A process ID, or PID, is simply a number used to identify a process.
The shell itself is represented by a process. Suppose the shell has PID 1. If the shell needs to execute ls, the
simulator might produce:
PID PPID STATE COMMAND
1 0 WAITING shell
2 1 RUNNING ls
PID 2 represents the simulated ls command, and its parent is PID 1, the shell. Once ls finishes, its state
becomes TERMINATED and the shell resumes running. You are not creating real operating-system processes
in this assignment. The Process structures exist only so that we can simulate and observe some of the behavior
that we will study later.
Visible OS Simulation
One important feature of this assignment is that the simulated operating-system activity should be visible.
For example:
/home/student -> ls
may display:
3
[OS] fork: process 1 created process 2
[OS] exec: process 2 is now executing ls
docs
names.txt
notes.txt
[OS] process 2 terminated
[OS] wait: process 1 waits for process 2
[OS] wait: process 1 resumed
These messages are not produced by the real operating system. They are printed by the simulator to show
what is conceptually happening. Later, when we use the real UNIX fork(), exec(), and wait() functions,
these operations will normally happen without being displayed.
Your Work
A significant portion of the shell framework is provided to you. Your primary responsibility is to complete
the simulated shell commands and the command-history system. You will also complete a small portion of
the simulated-process system. Do not use fork(), exec(), pipe(), wait(), system(), popen(), chdir(), or similar
operating-system facilities to implement the assignment.
PART 1: SIMULATED COMMANDS
Implement the functions used to simulate the shell commands. The required commands are:
ls
pwd
echo
cat
grep
wc
Each command works only with the simulated environment. For example:
ls
lists files from the Virtual File System. The command:
pwd
prints the shell’s simulated current working directory. The command:
echo hello world
produces:
hello world
The command:
cat notes.txt
displays the contents of the simulated file notes.txt. The command:
grep process notes.txt
displays each line of notes.txt containing the word process. The command:
wc notes.txt
4
counts the number of lines, words, and characters stored in the simulated file. You should not call the real
UNIX versions of these commands.
Command Input and Output
The simulated commands do not write their normal results directly to the screen. Instead, each command
produces a string containing its output. For example, the simulated ls command might place:
docs
names.txt
notes.txt
inside an output buffer. This is important because the output may later be sent to another simulated
command through a pipe.
PART 2: HISTORY
Your shell must remember recently entered commands. Every valid command entered by the user should be
stored in the history table. For example:
/home/student -> ls
/home/student -> pwd
/home/student -> cat notes.txt
/home/student -> history
should display something similar to:
1. ls
2. pwd
3. cat notes.txt
4. history
The history structure has a fixed maximum capacity. Once the table becomes full, the oldest commands
may be replaced by newer commands. The history exists only while the shell is running. You do not need
to save command history to a real file.
PART 3: SIMULATED PROCESSES
Most of the process simulator is provided. You are not expected to implement a real process-management
system. In fact, for this assignment, a Process is simply a structure representing a command currently
known to the simulated operating system. The process table contains several Process structures, and you
will complete selected operations associated with this table. These operations may include:
• finding an unused process-table entry
• assigning a new PID
• recording the parent PID
• changing the state of a process
• changing the command being executed
For example, when the shell simulates creating a process for ls, the table may change from:
PID PPID STATE COMMAND
1 0 RUNNING shell
to:
PID PPID STATE COMMAND
1 0 WAITING shell
5
2 1 RUNNING ls
After ls completes:
PID PPID STATE COMMAND
1 0 RUNNING shell
2 1 TERMINATED ls
The provided simulator will use this information to display the activity of the simulated processes. Remember
that none of these are real operating-system processes.
PART 4: SIMULATED PIPES
The shell supports a single pipe between two commands. For example:
ls | wc -l
The output produced by ls becomes the input supplied to wc. Conceptually:
ls ———> PIPE ———> wc -l
output input
The pipe is simulated using memory. No call to the UNIX pipe() function should be made. For example,
suppose ls produces:
docs
names.txt
notes.txt
That text is stored in the simulated pipe. The wc command then receives the same text as its input. The
visible trace may look similar to:
[OS] pipe: created simulated pipe 1
[OS] fork: process 1 created process 2
[OS] fork: process 1 created process 3
[OS] process 2 stdout -> pipe 1
[OS] process 3 stdin <- pipe 1
[OS] exec: process 2 is now executing ls
[OS] process 2 terminated
[OS] exec: process 3 is now executing wc
3
[OS] process 3 terminated
You should think about the pipe simply as a temporary place where one command’s output can be saved
and supplied to another command.
PART 5: OUTPUT REDIRECTION
The shell also supports simulated output redirection. For example:
echo hello world > hello.txt
normally means that the output from echo should be written to hello.txt instead of being displayed on the
screen. In this assignment, hello.txt is created inside the Virtual File System.
No real file should be created on the computer. The following commands should therefore work:
echo hello world > hello.txt
ls
cat hello.txt
and produce something similar to:
6
docs
hello.txt
names.txt
notes.txt
followed by:
hello world
Built-In Commands
Some commands are handled directly by the shell rather than by a simulated child process. These include:
cd
history
ps
help
trace
exit
For example:
cd docs
changes the simulated current directory maintained by the shell. The command:
ps
displays the simulated process table. The command:
trace off
turns off the visible [OS] messages. The command:
trace on
turns them back on.
Points
Remember, your grade reflects how effectively your solution solves the problem within the defined boundaries,
rather than whether your code mirrors the instructor’s exact implementation. Functional logic, proper use of
provided tools, and adherence to project rules carry significantly more weight than matching stylistic choices
or output formats line-for-line. Please refer to the RUBRIC.txt file for further details.
General Notes
• To earn the highest marks, your program should actively prevent errors whenever possible. Good
programming practice involves detecting and handling errors early, rather than allowing them to propagate.
• All declared variables must be used.
– Do not use global variables unless the assignment explicitly requires them.
– Prefer local variables whenever possible.
– Use clear and meaningful variable names.
7
• Use proper indentation and comments. Comment your source code according to the requirements
specified in the rubric, and format your program using a text editor or an IDE so that it is easy to
read. If your code is not properly formatted, we will not be able to assist you and will ask you to
correct the formatting before proceeding.
– All lines of code at the same block level must use consistent indentation.
– Inner blocks must be indented by at least two spaces relative to their enclosing block.
• Do not attempt to implement everything at once. Instead, write and test one execution routine (or
function) at a time. Compile and run your program frequently — after writing just a few lines — to
ensure correctness before moving on.
• Do not overlook presentation. Your program must neatly display both output and error messages.
Ensure that your output matches the provided sample output exactly, as CodeGrade is strict about
formatting.
• Your program will be tested with different inputs, so hard-coded output will be detected. Submitting
such a solution will result in a score of zero.
• Do not search for solutions online — you will not find any.
• If you have questions or need clarification, feel free to reach out for help.
Restrictions
• You are not allowed to include any additional libraries or external files in your program.
Everything you need to complete this assignment has already been provided in the starter code or is
part of the standard functionality required for the task. Do not include anything else. Including any
libraries or files beyond what is explicitly provided or required for the assignment will
result in severe consequences, including a failing grade for the course. We have instructed
the TAs to carefully review all submissions for unauthorized inclusions.
• Any alterations to the provided function specifications — including changing the function
signature, modifying the return type, removing or changing parameters, or introducing unauthorized
helper functions — will violate the constraints of this assignment and result in an automatic
grade of zero.
Consequences of Non-Compliance
Failure to adhere to this rule will result in:
• An automatic failing grade for the course.
• Submission flagged for review by academic integrity policies.
• Permanent record of the violation with possible further disciplinary actions.
Final Reminder
Everything you need to succeed in this assignment has already been given to you. Focus on understanding
and using the provided tools effectively. Do not jeopardize your academic standing by attempting to include
unnecessary or unauthorized elements in your code. If you are unsure about any aspect of the assignment,
please consult your instructor or TAs for clarification.
8
Agreement
By submitting your assignment to CodeGrade for grading, you are agreeing to the terms and conditions
outlined in this assignment. This agreement signifies your acknowledgment of the rules, requirements, and
restrictions stated within the assignment instructions. Furthermore, you understand and accept the actions
that will be taken if you fail to follow these instructions. This includes, but is not limited to, compliance
with restrictions on including unauthorized libraries or external files, adherence to submission deadlines, and
ensuring your program adheres to the specified criteria for success.
Any violation of these terms — whether intentional or accidental — will result in consequences such as
a failing grade for the assignment or course, as well as potential review under academic integrity policies.
By proceeding with your submission, you affirm your commitment to completing the work in accordance
with the provided guidelines and confirm that your submission is your own, original work, completed within
the parameters established by this assignment. If you are unclear on any aspect of these terms, it is your
responsibility to seek clarification before submitting your work.
Sample Run
% gcc -std= c90 – pedantic – Wall – Wextra sim_shell . c -o simshell
% ./ simshell
Submission
• All code submissions must compile and execute successfully.
• Zero Tolerance for Compilation Errors: If your code fails to compile, you will receive a grade of zero
for the assignment.
• No “Local Machine” Exceptions: We will not accept the argument that “it compiles on my computer”.
It is your responsibility to ensure that your code runs properly outside of your personal development
environment.
• Testing Recommendation: Make sure that your solution runs completely before submitting. To be
entirely safe, we recommend verifying that your code builds and executes successfully on any standard
Linux distribution prior to final submission.
• Submit the source file(s) to Canvas by the deadline.

Solution Overview

The assignment covers implementing simulated ls, pwd, echo, cat, grep, and wc commands, bounded command history, process-table operations, in-memory piping, and virtual output redirection. It also addresses built-in shell commands, simulated operating-system traces, error handling, and C90 compliance.