CMPS-3600 11am - Operating Systems - Lab-1

Elements of this lab...
  • Setup your Odin account
  • Work with the C programming language
  • Refactor a C++ program to ANSI C
  • Modify your C program
  • Build and run an X11 windowed C program

Lab instructions

Step-1 Setup your work folder on the Odin server... 1. Log in to Odin ssh username@odin.cs.csub.edu 2. Change to your home directory cd 3. Run a bash script /home/fac/gordon/p/3600/build_dirs.sh
Step-2 Do this work in your Odin 3600/1/ folder Follow along... We will write a C++ program together. 1. name your program fileio.cpp 2. get the user's name 3. get a number from the user 4. open a file named "log" 5. write the user's name to the file 6. calculate the summation from 1 to user's number, using a for-loop 7. write the summation total to the file 8. close the file 9. end the program Build and run the program like this: g++ fileio.cpp -Wall ./a.out Now we will refactor the program to the C language. Follow along...
Step-3 Stay in your 3600/1 directory. Copy a few more files in now.
$ cp ~gordon/public_html/3600a/examples/1/* . $ make $ ./xwin89
You should see a small window pop up on your screen. If not... You may need to re-login to Odin, like this... ssh -YC username@odin.cs.csub.edu The YC options Y says transfer to me the X11 window graphics C says try to compress the transmission for efficiency Try it now. Here are some modifications to make in the program... 1. Change the background to a beautiful gold color. --------------------------------------------------- Use XSetForground and XFillRectangle. Look up these X functions on google. Show where you found the information in a C-style comment. 2. When the mouse moves within the window, print 'm' to terminal. ----------------------------------------------------------------- Call the printf function. Flush the output buffer with each call of printf. Do not print a newline character! 3. Optional: Display some text in the window. --------------------------------------------- man XDrawString The text you print might be your name. It might be some instructions such as: Press 'A' key to see our school colors. Then, each press of 'A' will change the window background color to blue, gold, blue, gold, etc.
Step-4 Add the fileio.c program build to your Makefile. Running make will now build both programs. Try this: make clean make make