Week 10 Laboratory Exercises

Objectives

  • practice using POSIX threads in C
  • learn how to fix broken concurrent code
  • write a higher complexity concurrent program

Preparation

Before the lab you should re-read the relevant lecture slides and their accompanying examples.

Getting Started

Set up for the lab by creating a new directory called lab10 and changing to this directory.
mkdir lab10
cd lab10

There are some provided files for this lab which you can fetch with this command:

1521 fetch lab10

If you're not working at CSE, you can download the provided files as a zip file or a tar file.

Exercise — individual:
Compile C Files

INTERNAL ERROR MISSING SOURCE FILE: activities/compile_c_files/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest compile_c_files 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab10_compile_c_files compile_c_files.c

You must run give before Monday 18 November 12:00 (midday) (2024-11-18 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Fix a data race

INTERNAL ERROR MISSING SOURCE FILE: activities/fix_race/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest fix_race 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab10_fix_race fix_race.c

You must run give before Monday 18 November 12:00 (midday) (2024-11-18 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Fix a deadlock

INTERNAL ERROR MISSING SOURCE FILE: activities/fix_deadlock/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest fix_deadlock 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab10_fix_deadlock fix_deadlock.c

You must run give before Monday 18 November 12:00 (midday) (2024-11-18 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Create a chain of threads

INTERNAL ERROR MISSING SOURCE FILE: activities/thread_chain/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest thread_chain 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab10_thread_chain thread_chain.c

You must run give before Monday 18 November 12:00 (midday) (2024-11-18 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Challenge Exercise — individual:
Compile C Files If Needed

INTERNAL ERROR MISSING SOURCE FILE: activities/compile_if_needed/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest compile_if_needed 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab10_compile_if_needed compile_if_needed.c

You must run give before Monday 18 November 12:00 (midday) (2024-11-18 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Submission

When you are finished each exercises make sure you submit your work by running give.

You can run give multiple times. Only your last submission will be marked.

Don't submit any exercises you haven't attempted.

If you are working at home, you may find it more convenient to upload your work via give's web interface.

Remember you have until Week 11 Monday 12:00:00 (midday) to submit your work without receiving a late penalty.

You cannot obtain marks by e-mailing your code to tutors or lecturers.

You check the files you have submitted here.

Automarking will be run by the lecturer several days after the submission deadline, using test cases different to those autotest runs for you. (Hint: do your own testing as well as running autotest.)

After automarking is run by the lecturer you can view your results here. The resulting mark will also be available via give's web interface.

Lab Marks

When all components of a lab are automarked you should be able to view the the marks via give's web interface or by running this command on a CSE machine:

1521 classrun -sturec