Marquette University logo      

How to Run POSIX Threads, Figure 4.6

 

Materials

 

We are going to run the POSIX threads code thrd-posix.c, Fig. 4.6.

In this discussion, you may substitute <yourfavoriteunixbox> for <eng-feta.eng.mu.edu>

 

Preconditions:

  1. Install SSH client, see How to Get and Run SSH
  2. Log into eng-feta.eng.mu.edu, see How to Get and Run SSH

1. Get examples

You should execute this sequence once to copy all the book's examples from my directory to yours. "#" introduce a comment in UNIX scripts. "#" and text following need not be entered

   cd       # Ensure you are at your home directory
   mkdir COEN183     # Make a new directory for this class
   cd COEN183        # Change to the directory
   mkdir osc7e-src   # Make a new directory
   cd osc*           # Change to that directory.  Wild cards work
                     # Copy contents of my directory to your current directory
                     # Final period is necessary in UNIX, not in MS DOS
   cp -r ~corlissg/COEN183/osc7e-src/* .

If you prefer, you can save the code thrd-posix.c to your machine and transfer it to eng-feta using the secure FTP client.

See more detailed discussion of some Unix commands you'll need

Compile and run the POSIX example

   cd chap4
   ls   # List files.  Should see thrd-posix.c
   gcc -o thrd-posix thrd-posix.c -lpthread   # Compile
   thrd-posix        # Run.  Should give an error
   thrd-posix 100
or just
   make

The command "make" invokes the script in the file Makefile

 

 

Next:

 

 
  Marquette University. Be The Difference. Marquette | Corliss |