(Latest Revision: Wed Nov 1 21:04:31 PDT 2017 ) setupDirections

setupDirections



- DIRECTIONS FOR GETTING STARTED - 

- GETTING COPIES OF THE FILES WHERE THEY NEED TO BE - 

Login to a lab mac

Go to Finder (First Icon on the Left in the 'Dock')
  Go to Finder preferences
  In preferences, go to the top where it says "Sidebar" and click on that
  Under Favorites, make sure there's a check mark next to the 'little house'
    (This makes sure that an icon representing your home directory will be
      displayed in the sidebar when you select files.)
  Click on "General" and make sure to select your home directory (little house) 
      in the drop-down menu under "New Finder windows show:"
  Click on "Advanced"
      Make sure "show all filename extensions" is checked
  Dismiss the preferences window by clicking on the red dot

Start up TextEdit (Blank paper and pen icon in the Dock, 
                     or Finder Window -> Applications -> TextEdit.app)
  Go to preferences.
     Click on "NewDocument" at the top
        Make sure "Plain Text" is selected under "Format"
        Also make sure "correct spelling automatically is un-checked"
     Click on "Open and Save" at the top
        Make sure that 'Add ".txt" extension to plain text files' is NOT checked.
  Dismiss the preferences window by clicking on the red dot

Start up Safari or Firefox
Create a new file with TextEdit (File -> New)
Navigate in the web browser to the assignment cover page
 https://www.cs.csustan.edu/~john/Classes/CS3750/Prog01/
Select "Program Skeleton (Shell)" on the assignment cover page.
Follow the directions to select and copy the text to the clip board 
   (Edit -> Copy works, or command-c on keyboard)
Paste the clipboard contents into the new file window (Edit -> Paste, or command-v)
Enter the save command in TextEdit (File -> Save)
Click on the sidebar on the 'little house' icon for your home directory
Click on the bottom left where it says "NewFolder"
Type Prog01 or some such name for the name of the directory and click on the "Create" button
In the "Save As" panel at the top, type sequence.cpp for the name of the file.
Then click on bottom right where it says "Save"

Create three more files with TextEdit, and using procedures like you did for 
  sequence.cpp, make copies of files sem.cpp, sem.h and Makefile.
  (Those are the exact names the files need to have.)  
  Save all the files to the same directory where you saved sequence.cpp 
  (Of course, you only need to create the directory once.)

- COMPILING AND RUNNING THE PROGRAM - 

Start up Terminal (Click on the icon that looks like a computer screen in the Dock,
     or Finder -> Applications -> Utilities -> Terminal.app)
'cd' to the directory where you put the files - you would enter 
cd Prog01
if you named the directory Prog01
Enter the ls command
The shell should print the names of all the files - like this

john@lucifer: ls
./              Makefile        sem.h
../             sem.cpp         sequence.cpp

now enter the single command 

make

You should see something like this

john@lucifer: make
g++ -c sequence.cpp
g++ -c sem.cpp
g++ -o sequence sequence.o sem.o
john@lucifer: 

(except your shell prompt is something different from "john@lucifer")

Now do another ls

john@lucifer: ls
./              Makefile        sem.h           sequence       sequence.o
../             sem.cpp         sem.o           sequence.cpp
john@lucifer: 

The file called sequence is your compiled program.  Enter its name to execute it

Something like this happens

john@lucifer: sequence

Welcome to The Child Thread Workplace!

Mother Begins Spawning Threads.

Child # 1 has completed its assignment.
Child # 5 has completed its assignment.
Child # 4 has completed its assignment.
Child # 2 has completed its assignment.
Child # 0 has completed its assignment.
Mother Finishes Spawning Threads.


All children have now reported that they finished.
The value of the thrds_finished counter is: 1.
BAD COUNTER VALUE!! - Critical Section Problem Failure!!
Mother exiting ... 

Child # 3 has completed its assignment.
john@lucifer: 

- EDITING THE PROGRAM -

You will want to edit the sequence.cpp file.  
If you find sequence.cpp using the Finder and double click 
on its icon, the Xcode application will probably open it.
You can use Xcode to edit sequence.cpp.  (I don't particularly
like that idea.)  Another option, which I personally like better,
is to use TextEdit or some other simple text editor to edit sequence.cpp.
If you have an editor you like, feel free to use it.  To use TextEdit, just
go to the File menu in TextEdit, choose "Open", navigate to sequence.cpp in
the browser, and click on "Open" in the bottom right of the window.  
Then you can make whatever changes you want.  
Pico is an editor that you can use from a terminal window, either the Terminal app
or the terminal window you get when you do remote access from, say, your computer 
at home.  

(So pico is awesome because it allows you to edit the file on the remote 
lab computer while you are at home.) 

To run pico, cd to the directory containing sequence.cpp, and then enter

pico sequence.cpp

Pico will start up, and you can edit the file.  There will be a little menu at the
bottom of the screen telling you what the editor commands are that you need to know.