Homework 1 Due Jan. 19 [ But hw2 will be assigned Tuesday, Jan. 16. ] ====== SOME WORDS OF ADVICE FOR ALL HOMEWORKS IN THIS COURSE: Linux began as a command-line system. It is the most common operating system when building open-source programs. The principles that you will learn can also be applied to the other common operating systems. But this course will standardize on Linux as our common point of reference. There are many good introductions to Linux. LEARN IT! In testing your Linux programs, we will always use: login.ccs.neu.edu (aka login.khoury.neu.edu) Make sure that you can use 'ssh' and 'scp' to to develop on the "login" machine. If your homework doesn't work on "login", then your homework is not working. It is strongly advised to develop entirely by using EITHER: * WSL2 (if a Windows laptop); or * Apple terminal (but beware of incosnistencies with Linux); or * or 'ssh' and develop directly on the "login" machine. Please get used to 'vi' (or 'make vi'), so that you don't depend on a graphics interface. Linux, at its core, is command-line oriented. Hote that the help directory has an easy and fun way to get started with 'vi'. ====== HOW TO SUBMIT hw1: The method for submitting will be used by this and most future homework assignments. Even though future homeworks will not always describe the details of submission, please consider these instructions to be the default. These instructions assume that your hw1 directory is on login.ccs.neu.edu. 1. You should always test if your homework is working, by using the command 'make check' _on the computer login.ccs.neu.edu_. The graders will also be running 'make check' on login.ccs.neu.edu. 2. You must include in your hw1 directory a README file. If everything works, write that in the README file. If some elements of your homework don't work, then you must document the portion of your homework that doesn't work. If some portion of your homework doesn't work, and you didn't document it in your README file, then the grader will deduct extra points. 3. Next, you are ready to create a "tarball" for your homework. You can easily create a tarball by typing the command 'make dist'. 4. You must then submit your homework. /course/cs3650/homework/submit-cs3650-hw1 ../hw1.tar.gz As an example, here is what happens when I create a tarball and submit the tarball to the "handin" directory. LOGIN-STUDENTS:hw1% make dist ... -rw-r--r--. 1 gene faculty 3918 Jan 12 12:30 ../hw1.tar.gz LOGIN-STUDENTS:hw1% /course/cs3650/homework/submit-cs3650-hw1 ../hw1.tar.gz dir: /net/course/cs3650/homework/hw1.handin to_file: /net/course/cs3650/homework/hw1.handin/gene-hw1.tar.gz.93326561 ... ====== In this homework, you will build a menu system that offers to execute several Linux commands. Please read everything in Makefile, and familiarize yourself with the targets: make make fork-exec make vi make clean make check make dist In fork-exec.c, you will need to modify any line of code that refers to "HOMEWORK". Your code should execute the intended action for each menu item. First, make sure that you know the basic Linux commands. The course web page suggests: https://www.chm.bris.ac.uk/unix/ as one example of the many good Linux tutorials on the Web. You may need to use commands like 'man 2 fork' and 'man 3 printf' in order to understand better the Linux system calls that you need for this homework. Please note that the directory includes: fork-exec-example.c This should help you to understand some of the system calls. To experiment, do: cd cp -g3 -O0 fork-exec-example.c ./a.out Then try GDB: gdb --args ./a.out In order to learn GDB, briefly review the sections: "INVOKING gdb:" "COMMON gdb COMMANDS:" Then practice these techniques on: gdb --args ./a.out In class, we will demonstrate GDB. You can run GDB on fork-exec.c in hw1 by: make gdb As before, there is a good overview of GDB near the end of the course web page. GDB is the "debugger". But informally, you can view it as an interpreter for the C language. As with Python, C is much easier to understand and debug when you can execute it as an interpreter. In class, we will also demonstrate the 'vi' or 'vim' editor. It is recommended to do all of your code development directly on login.ccs.neu.edu by using a terminal window, using 'ssh'. This is _not_ a graphic interface. So, you should learn an editor that does not depend on graphics. 'vi/vim' is the most popular editor for Linux. It is easy to learn. A painless way to learn it is to do: cd cp /course/cs3650/help/vitutor.vi ./ vi vitutor.vi # And then follow the instructions