Skip to main content
4 credit course

We understand that the material and Assignment 1 may feel challenging, especially if you are not fully comfortable with the prerequisites. If you find yourself struggling or feeling overwhelmed, we kindly encourage you to consider taking this course in a different term once you have built up the required prerequisites. Your success and learning experience are important to us, and we want to ensure that you have a positive and fulfilling journey in this course.

Either MACM 101, and CMPT 125 or CMPT 130/135. or MATH 151 and CMPT 102 for students in an Applied Physics program, all with a minimum grade of C-. Please see here for prerequisites we expect you to know from prior courses:

As outlined above, we expect prior courses to provide the requisite C or C++ knowledge with experience in working with the Linux terminal/shell. If you do not have this experience, please head to the tutorials page and follow the tutorials, and self-learn using the videos we post and recommend. All assignments and labs in this course are administered through the Linux environment and assume you have the prerequisites.

If you are not comfortable working with C/C++ and the Linux terminal at SFU, it is possible that you may not have the prerequisites for this course, regardless of your grade in the prior course. We kindly recommend speaking to an academic advisor for further guidance.

Linux knowledge

Solid programming skills (C). Working at shell/terminal in Unix/Linux.

Quick Start Guide

Environment: Use CSIL machines or the provided VM. Contact helpdesk@cs.sfu.ca for CSIL issues.

Prerequisites: C/C++ programming and Linux terminal experience from CMPT 125/130/135. If you need a refresher, please refer to our tutorials and videos for self-learning. While we understand that CSIL and Linux can be challenging, we’re unable to provide direct support for SSH or CSIL access questions.

Terminal Usage Prerequisites include terminal experience from prior CMPT courses. If needed, use our tutorials and videos for self-learning. No direct terminal support provided. Windows users: Use the VM below or set up Windows Terminal with WSL and VSCode Remote SSH.

Choose Your Setup:

SSH TO CSIL

# Replace SFUID below with the id in coursys e.g., mine is ashriram. Yours will be different. You can try cpu1-10 below if 6 does not work
$ ssh [SFUID]@csil-cpu6.csil.sfu.ca	-p 24
  • Optional: Remote Desktop. You may find machines using links below You will be connecting into linux machine WE DO NOT SUPPORT WINDOWS

Finding CSIL Desktops

To work remotely with CSIL you need to find free machines.Typically these are listed [here]- SSH to CSIL. If that page is down or is not working for you. Then you can use the option below or mail helpdesk@cs.sfu.ca

Option 1 Use the script below.

# Replace SFUID below with the id in coursys e.g., mine is ashriram. Yours will be different.
$ ssh [SFUID]@csil-cpu6.csil.sfu.ca	-p 24 
# If cpu6 is down you can try others listed here: https://www.sfu.ca/fas/computing/support/csil/unix/cpu-servers.html
# On a shell on the CSIL server
$ wget "https://www.cs.sfu.ca/~ashriram/Courses/CS295/assets/distrib/csil-linux.py"
$ python3 csil-linux.py
# e.g., You will get a dump of machine names. These are machines currently running the linux environment.
# The names below will vary each time you run it.
asb10928-d06.csil.sfu.ca
asb10928-e02.csil.sfu.ca
........

WARNING 1: Remote access is shared - save frequently as physical users may reboot machines WARNING 2: SSH availability doesn’t guarantee RDP support. For RDP issues, contact helpdesk@cs.sfu.ca

VSCODE CSIL WITH VPN

Tunneling By using this method, we can run the vscode editor locally on our laptop while editing files on remote CSIL machines and running commands on Linux remotely. Video below assumes you have already completed ssh setup

VM

Note: Self-guided setup. No technical support provided.

  1. Download VirtualBox
  2. Download VM, CMPT295.vmdk and CMPT295.vbox WARNING: Not U20
  3. Import instructions
  4. You can ssh into the VM from your machine. Port 2222 on the host machine maps to port 22 on VM.
     ssh -p 2222 vagrant@localhost (username: vagrant password: vagrant)
    

Limitations: Not supported on M1 Macs, Chromebooks, or ARM devices. If you encounter any difficulties with the VM, we suggest following the CSIL instructions as an alternative.

Modules

Load required software (run once per session):

  • ON VMs: These come preinstalled.
  • On CSIL. If RDPed or SSH. Open Applications>Utilities>Terminal
$ module avail
# If module command is not found
$ export LD_LIBRARY_PATH=/usr/shared/CMPT/courses/cmpt295/tcl/lib:$LD_LIBRARY_PATH
$ source /usr/shared/CMPT/courses/cmpt295/modules/Modules/3.2.10/init/bash
$ module avail
# If you see some Tclerror etc. Then you have not set the LD_LIBRARY_PATH
# Step 2
$ module load cmpt295/cgdb
$ module load valgrind 
$ module load cmpt295/riscv

# Load python environment
$  . "/usr/shared/CMPT/courses/cmpt295/miniconda3/etc/profile.d/conda.sh"
$ conda activate

Alternative if your are not able to get above steps working

# Add this to the file ~/.bashrc if you want to automatically have cgdb loaded each time.
export PATH=/usr/shared/CMPT/courses/cmpt295/cgdb/bin:$PATH
export PATH=/usr/shared/CMPT/courses/cmpt295/valgrind/bin:$PATH

If on VM. We preload the software.

$ module avail
# If on VM you do not need to do anything.
## VM
# Your shell should say (base).....
# If module avail says command not found
# then you are most likely in the wrong shell/terminal
Linux Cheats

Your home directory is shared between the CPU servers, so you can copy files to or from there by connecting to one of the CPU servers. The files will be available on the workstations. Copying files to CSIL will be something like:

scp -P24 filename USERNAME@csil-cpu1.csil.sfu.ca:

And back from CSIL:

scp -P24 USERNAME@csil-cpu1.csil.sfu.ca:filename .

These assignments may need you to navigate through multiple source files. If you do not have a favorite editor then I would highly recommend the following.

  • vscode, installed in your VM. You need an RDP session or VM. It will not work within a terminal. You can pull up vscode by typing code in your terminal (VM or RDP-only). CSIL Instructions with VSCODE
  • [emacs] is already installed in CSIL and VM.
  • Cheats emacs
C tools
  • Essential C
  • Cheats C
  • C Tutor. A tool to visualize the memory layout and objects in C programs.
  • Repl.it. To try programs without installing compiler etc on your local machine.
  • Valgrind You should use valgrind to check your code for memory leaks.
  • gdb
  • valgrind
$ valgrind -q --leak-check=full ./main
# If on VM. It will analyze code and may report errors
# This is best effort, while valgrind is more thorough
$ scan-build -k -V ./main