====== C language lab ====== ===== Description ===== * To get to know the lab environment. * Basic process creation and shared memory handling in C language. ===== Lab Contents ====== - Introduction to the 116 Lab - GNU Linux environment - login/logout - Graphical User Interface - GUI: - localization - window handling - file management, editing - Command Line Interface - CLI: - shell: bash - localization: ''locale'' - your friend: ''man'' [section] topic \\ (note: man displays the manual through a //pager// which allows to scroll (up/down arrows) and search (/keyword), to exit just press ''q'' as quit) - file management: ''ls'', ''cd'', ''cp'', ''mv'', ''mkdir'' - process management: ''ps'', ^z, ''jobs'', ''fg'', ''bg'', &, ''echo $?'' - command history (up/down arrows), history search: ^r - Editors: gedit - C compiler - ''gcc -Wall source_file.c -o executable_file'' - to run an executable issue: ''./executable_file'' - Download and save the following example example: {{hello_world.c}} - Read the above program, is everything clear to you? - What does the following variables do: argc, argv, status? - Compile the program with gcc. - Run the program with different number of arguments. \\ Do you see what happens? \\ Do you know why? - Upon finishing check process exit (completion) status: ''echo $?'' - Shared memory - Currrent Shared Memory allocation can be investigated using the following tools: ipcs, ipcrm, ipcmk - Download and save the following program: {{shm.c}} - Take a look at it. What does it do? - Read the manual (using 'man' command) regarding the following function calls used in the program. What do they do? - sleep(): ''man 3 sleep'' - time(): ''man 2 time'' - srand(): ''man 3 srand'' - rand(): ''man 3 rand'' - What does ''stop'' message represent? - Compile the program and run it several times. - Why does it give different values each time it is run? - Make sure, that your processes clean up Shared Memory (use ipcs, ipcrm commands).