Web Resources for CS3650 (Computer Systems)


Instructor: Gene Cooperman
Spring Semester, 2024

NOTE:
The office hours are as stated on the syllabus (Tues. and Fri., 5:15 - 6:30; for Spring, 2024), and by appointment. I am typically still in my office at least until 7pm.

===============================

Course basics: Here are some immediate resources in the course for doing homework, following the readings, etc.

Course home:
The course materials will always be available either from this web page or from the course directory on the Khoury Linux computers: /course/cs3650/.
Syllabus:
The syllabus contains the required readings in the textbook. It's available from the link or from /course/cs3650/ (the course directory) on Khoury Linux computers. Note especially our online textbook ostep.org.
Homework:
The homework subdirectory of the course directory contains all course homework, and the course directory contains all handouts.
Help directory:
The course directory includes a help directory. There are two older reviews of UNIX there. But please consider this excellent modern introduction to UNIX by M. Stonebank. (or alt, with updates to Linux/bash by C. Tothill)
Linux:
The course is based on Linux (the third of the three popular operating systems). If you do not yet have a Khoury Linux account, get one. If you are not fluent in the basics of Linux/UNIX, please go to any of the good tutorials on the Web. Personally, I like: *** this Linux tutorial *** (from M. Stonebank, U. of Surrey, England), or this *** updated one for Linux/bash *** (by C. Tothill)
Other useful tips on Linux:
  1. Productivity tip: In most settings: the four cursor keys work (for editing the current or previous commands); and the <TAB> key works (for auto-completion of filenames and commands).
  2. If you're using Apple (the second most popular operating system), the terminal window provides you with a UNIX-like environment. It may differ from true Linux in small ways. You may need to install extra packages for Mac OS. You should still test your homework solution on the Khoury login commputer, since that will be the standard for correctness.
  3. If you're using Windows (the most popular operating system), you can install WSL (Windows Subsytem for Linux). Then go to the Microsoft Store, and install a Linux. If you are unsure of which Linux distribution to use, Ubuntu is a common first choice for those unfamiliar with Linux, especially an Ubuntu labelled "LTS" (Long Term Support". This gives you a Linux virtual machine side-by-side with Windows. Some "gotchas" and workarounds follow.
    If installing Ubuntu from the Microsoft Store and it fails with an error code, try executing wsl --update in PowerShell with admin privlege.
    After installing WSL, a known, older bug from May, 2021 causes the vmmem process to consume a lot of CPU time at wake-after-sleep, if WSL was running. There is a workaround here.
    Some people may also need to turn on virtualization in their BIOS. After entering BIOS, examine all options in all tabs with the letter 'v'. For me, the option was "AMD SVM".)
  4. In order to copy files between Windows and WSL, I create a link inside WSL to the 'Downloads' folder:
    cd
    ls /mnt/c/Users
    # For me, I am user genec in Windows. So, I then type:
    ln -s /mnt/c/Users/genec/Downloads ./
    # You can now copy (cp) between ~/Downloads and ~ in WSL,
    # where '~' is the Linux shortcut for your home directory.
  5. Similarly, you can copy between Windows Desktop and WSL. In my case, I type:
    cd
    ln -s /mnt/c/Users/genec/Desktop ./
    # OR:
    ln -s /mnt/c/Users/genec/OneDrive/Desktop ./
    # Try both forms. It depends on where Windows put your Desktop.
  6. Whether you use Windows/WSL or Apple Terminal, you'll need 'ssh' and 'scp':
    # Logging into Khoury login: (You'll need this to submit.)
    ssh USER@login.ccs.neu.edu # Replace 'USER' by your Khoury username
    # Copying your local laptop files to Khoury login: (You'll need this to submit.)
    # Note the ':' at the end. You can add a Khoury directory in your account.
    # Or, you can leave it blank after ':', and the file is copied to your home dir.
    scp myhw.tar.gz USER@login.ccs.neu.edu: # $Note ':'; Default dir
    For help, try: man ssh and man scp.
  7. And note one gotcha. If you use the wrong password three times with 'ssh', then Khoury login (as of 2025) logs your IP address, and locks you out for 3 days.
    WORKAROUND: Set up a hotspot with your smartphone, and connect your laptop to the hotspot. The smartphone will have a different IP address.
  8. But if you insist on using Windows, but not WSL, then please try putty (substitute for 'ssh') and WinSCP (substitute for 'scp'). For 'ssh' without WSL, you can alternatively install OpenSSH for Windows.
Linux editors:
Please also note the directory for UNIX (Linux) editors. On Khoury Linux, try: cd /course/cs3650/unix-editors. The editor vi is a popular choice. To learn vi (estimated time: one hour), login to Khoury Linux and do:
    vi /course/cs3650/editors-unix/vitutor.vi
and follow the on-screen instructions.
Common Linux Commands:
Here is one web site (Common Linux Commands) with about 30 common Linux commands. If you haven't used Linux much, try a quick review of these commands (passive knowledge only). If you need more, there are plenty of great text and video tutorials on the Linux command line.
RISC-V assembly language:
The assembly portion of the course will be based on RISC-V. Please download the RARS Simulator for RISC-V (inspired by MARS for MIPS assembly), for use with RISC-V assembly.
  1. Quick Reference: "RISC-V quick reference" online (or alt, but missing pseudo instructions; or alt) (all inspired by MIPS "green card")
  2. Assembly "cheat sheet": RISC-V "cheat sheet" (and for each instruction, click on the "Project F guide" at the right for a fuller description of that category of instructions)
  3. Home page for RARS simulator and documentation: RARS on github
  4. System calls: "Environment calls"
  5. Assembler directives: Assembler directives
  6. Assembly manual: Assembly instructoins supported by RARS
  7. Function calling convention: Conventions to make function calls (and system calls)

Google for RISC-V, and you'll find other RISC-V resources, but I find the above resources to be sufficient, and self-contained.

If you'd like examples of excerpts of RISC-V assembly, as translated from a C program, try the Godbolt Compiler Explorer (choose C language and "RISC-V (32-bits) gcc" from the menus in the two panes; and deselect "Compiler to binary object" in the "output" menu of the right-hand pane);
and see this post describing it: Project F: RISC-V Assembler: Compiler Explorer. In fact, the Compiler Explorer can generate the commonly used: RISC-V, MIPS, ARM, and x86-64 (Intel/AMD) assembly. And the Project F post even has more examples of paradigms for RISC-V, in case you didn't like the ones above.

And the Compiler Explorer can generate the assembly using the gcc compiler or the clang compiler.

C language:
We will assume knowledge of the C  language (the core of Java, but including primitive types, only). For a more extensive overview of C, consider a good, free on-line C book by Mike Banahan, Declan Brady and Mark Doran. Since Java does not have pointers, we will study C pointers in class.
GDB debugger, gcc compiler, etc.:
As you use Linux, please especially practice using GDB (GNU debugger). This will help when you test your homeworks under Linux. It will also reward you with more productive debugging for the rest of your computer science career. (Here are some local help files for Linux and its compilers, editors, etc., but please consult GDB closer to the bottom of this page, or else the rich set of help pages now on the Web.)
Python
See materials on Python, and the Python subdirectory
UNIX xv6
The original UNIX was small enough that one can read all of the code, with the right guidance. The UNIX xv6 subdirectory has an easy-to-read hyperlinked version of UNIX xv6, with about 7,000 lines of code (about 100 pages of code).
Thread synchronization
"thread-synch" subdirectory (notes on basic use of mutex, semaphore and condition variables)
Undergraduate tutoring (but no longer available):
Khoury College used to offer free undergraduate upper-class tutoriing as of 2020. It seems to be gone in recent years, but let me know if such a resource again appears.

Going beyond (enrichment material):

Text supplements (optional) for course:

RISC-V Simulator (RARS) for Assembly Language homework:

In Spring, 2025, we are now switching from MIPS to RISC-V CPUs. These old MIPS resources for MARS/MIPS may provide useful hints for when you use the RARS/RISC-V simulator. This is because RARS was inspired by MARS. But this section will eventually mostly be deleted, with minor parts updated for RARS.

  1. The software is distributed as a Java .jar file. It requires Java 8 or later. Here are installation instructions for Windows, and installation instructions for Mac, and manual isntall for all three operating systems.
  2. Then download RARS. Here is the RARS documentation. This leads you to the Downloads page (currently v1.6), which has a rars1_6.jar link. Click on the jar link, and you should now have RARS working.
  3. To begin running the simulator, go inside the folder, and double-click on the Mars.jar icon. Alternatively, if running from the command line in Linux, type: java -jar jars1_6.jar
  4. Here are some youtube RARS tutorials by XDoesTech (with transcripts): Part 1, Part 2, Part 3 (including syscalls), Part 3.1, Part 4.1: Memory, Endianness,. See his github page for reference information files and code files that he uses.
  5. Notice that the RARS documentation also has an examples folder, with some example RISC-V programs that you can run. However, most of those files are missing a "main" routine.
  6. And here is an old video of running the old MARS simulator. That will show MIPS assembly, instead of RISC-V assembly. But the video is still useful for showing the user interface of RARS: Online video demo of the Mars simulator.
  7. OLDER MARS; YOU NEED RARS: There is a MIPS Assembly language simulator with free downloads available (and local copy) and online documentation.
  8. GOTCHAS: There are several important things to watch out for (in the older MARS).
    1. The "Messages" pane at the bottom also keeps text from older runs. Click the "Clear" button before doing a new run.
    2. When you hit the "Assemble" menu item, any error messages about failure to assemble are in the bottom window pane, tab: "Mars Messages". Input/Output is in the bottom window pane, tab: "Run I/O"
    3. If you paste assembly code into the edit window pane, you must save that code to a file before Mars will let you assemble it.
    4. If you have selected a box with your mouse (e.g. "Value" box in the data window pane, or "Register" box), then Mars will not update the value in that box. Mars assumes you prefer to write your own value into that box, and not to allow the assembly program to use that box.
    5. If your program stops at an error, read the "Mars Messages" for the cause of the error, and then hit the "Backstep" menu item to see what caused that error. Continue hitting "Backstep" or "Singlestep" in order to identify the error.
    6. Your main routine must call the "exit" system call to terminate. It may not simply call return ("jr $ra"). Note that page B-44 of Appendix B of the text (fourth edition) has a table of "system services" (system calls). These allow you to do "exit" and also I/O.
  9. One of the nicer features of this software is a limited backstep capability (opposite of single-step) for debugging. In addition, the help menu includes a short summary of the MIPS assembly instructions. In general, I like this IDE for assembly even better than some of the IDEs that I have seen for C/C++/Java. (The one feature that I found a little unintuitive is that if you want to look at the stack (for example) instead of data, you must go to the Data Segment window pane, and use the drop-down menu at the bottom of that pane to choose "current $sp" instead of ".data".)
  10. I'd appreciate if if you could be on the lookout for any unusual issues, and report them promptly (along with possible workarounds), so the rest of the class can benefit. Thanks very much for your help on this.

===============================

The GNU debugger

GDB (GNU DeBugger):
  A Few Simple Debugging Commands Save You Hours of Work

        INVOKING gdb:
          gdb --args  
          Example:  gdb --args ./a.out myargs

        COMMON gdb COMMANDS:
          BREAKPOINTS:  break, continue
          STARTING:  break main, run
          WHERE AM I:  info threads, thread 1; where, frame 2; list
          PRINT:  ptype, print  (   ptype argv[0]; print argv[0]   )
          EXECUTING:  next, step, until, finish, continue
            (next line, step inside fnc, until previously
             unseen line (escape a loop), finish current fnc,
             continue to next breakpoint)
          EXIT:  quit
          < Cursor keys work, TAB provides auto-complete >
          PARENT AND CHILD PROCESSES:
            set follow-fork-mode child
              (after call to fork(), switch to debugging child process)
          DEBUGGING INFINITE LOOP:
            run; TYPE ^C (ctrl-C) TO TALK TO gdb; where; print var1; etc.
          HELP:  help    e.g.: (gdb) help continue

        ADVANCED gdb: USING gdbinit:
          In a more sophisticated debugging session, you may have to try
          multiple GDB sessions.  To do this, you will want to try doing:
            gdb -x gdbinit --args ./a.out myargs
          First, create a gdbinit file. An easy way is, in your last GDB session,
            (gdb) show commands
          Then copy-paste those comamnds into gdbinit and edit as desired.
          Then at the top of gdbinit, insert:
            # gdb -x gdbinit --args ./a.out myargs  [Customize as needed]
            set breakpoint pending on
            set pagination off
            # Stop if about to exit:
            break _exit           
            # Continue w/ output of 'show commands'; Extend and modify as needed

        MORE ADVANCED gdb:
          info function 
            IF DEBUGGING C++ CODE, you will find this useful, in order
            to discover the full GDB name of your target method.
          macro expand MACRO_FNC(ARG)  [requires 'gdb -g3']
          debugging child after fork:
            set follow-fork-mode child
            break fork
            run
          EXTENDED "WHERE AM I":
            set detach-on-fork off
            info inferiors; inferior 2
            info threads; thread 1
              NOTE:  The qualified thread number is: .
                     So, 'thread 2.3' switches to thread 3 in inferior 2.
            where; frame 2
            list; print myvariable
And for the adventurous, consider this full-featured GDB Dashboard. It's a nicer version of things like "layout src". For digging deeper into GDB, try: "gdb - customize it the way you want".

  NOTE: For those who like a full-screen display of the current code, try the command ^Xa (ctrl-X a) to turn full-screen mode on and off. Also, try: (gdb) layout split
And finally, try "focus cmd" and "focus src", or ^Xo, to decide which pane you want your cursor keys to operate on.

  NOTE: For those who like to try a reversible version of GDB, see rr-project.org (for GDB with reverse execution)

  NOTE: For a _really cool_ GDB interface, look at: https://github.com/cyrus-and/gdb-dashboard. To try it out, just go to the .gdbinit file from that web site, and then copy the code into a local file, gdbinit-dashboard, and then execute source gdbinit-dashboard in GDB. Personally, I like to use Dashboard by displaying the whole dashboard in another terminal.

===============================
Python

There are some good introductory materials for Python in the instructor's directory. After trying those out, here are some other Python background materials:

Python

===============================
Current Events

NEWS (from 2024 and earlier):
SPECULATION ABOUT FUTURE CHIPS AND THE END OF MOORE'S LAW:       For context, note the Wikipedia Silicon article on the covalent radius of silicon is 0.111 nm. So, the distance between adjacent silicon atoms is the diameter (0.222 nm).
       7 nm is approximately 31.5 silicon atom diameters. 5 nm is approximately 22.5 silicon atom diameters. 3 nm is approximately 13.5 silicon atom diameters. 2 nm is approximately 9.0 silicon atom diameters.

       Motivation for multi-core CPUs: Limits of CPU Power Trends at beginning of the millenium (or alt)
       Future of CPU trends and Moore's Law: The Future of Computing Beyond Moore’s Law (Jan., 2020)