PA stands for the Project Assignment of the Computer Systems course at Nanjing University. In this special assignment, we will use software to simulate hardware functions and build a simple computer system from scratch.
Thanks to the genius curriculum design of the School of Intelligent Science and Technology, I need to complete the 2024 version of PA during this winter vacation, and I’m recording the interesting things that happen during the process here for others’ reference and for my own memory. Of course, since PA is a course assignment after all, I need to respect the teachers’ requests and will not describe too many implementation details in these records.
Environment Preparation
Given that the entire PA is required to be completed in a Linux system, and I am also quite lazy, I chose the simplest solution – WSL2 (Ubuntu 22.04 distribution).
Before we start writing code, we need to install some necessary development tools. As everyone knows, in Linux systems, you can use package managers to conveniently download and install software. However, Ubuntu’s package manager apt requires sudo privileges to run, yet the download and installation code in the handout very annoyingly didn’t add sudo, and it was written on multiple lines, which means we must copy each package repeatedly.
Unacceptable!
Therefore, I copied the packages that need to be downloaded into a file named file, and used a bash script for data processing to directly extract the list of package names to be downloaded and installed them. I’m posting the code I used below.
1cat file | sed -E 's/^apt-get install (.*) *# .*$/\1/' | paste -s -d " " | xargs sudo apt-get install
Much faster than copying them one by one (doge). But if you don’t do this, what’s the point of using CLI?
Another interesting thing happened during the environment configuration process. While configuring ccache, I accidentally wiped out my environment variables when adding them to .bashrc (explained here). Since the error occurred in .bashrc, a simple restart could not solve the problem, and since all environment variables were gone, it meant I couldn’t even directly use vim to modify .bashrc.
After solving this problem and restarting WSL, I found that the paths in Windows could not be properly converted. I just needed to run:
1wsl --shutdown
in pwsh and then reopen wsl to solve the issue.
Some Thoughts
Although I just started working on it today, I can already feel how much wisdom from teachers and seniors is condensed in this PA. This assignment has moved beyond simply introducing how to build a computer system; it further embodies the spirit that any CS course should have – exploration and tinkering.
I’ll borrow the words of Teacher jyy as a conclusion: Teacher Jiang, can you please come teach us OS :(
We are all living people, and since childhood, we have been involuntarily taught to get the maximum return with minimal effort, often forgetting what we truly want. I admit I am a perfectionist, but I think everyone has a thirst for knowledge and a yearning for truth in their hearts. The soul of a “university” lies in the innocence and ideals that transcend the secular and transcend the era – we are not graduates trying to please enterprises, but seekers of the power to change the world.