PA 8001 2014 Practical 2

From CERES
Revision as of 06:39, 27 September 2014 by Ceres (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Objectives

There are three main objectives for this practical:

  • Learn about and implement the basic ingredients for concurrency,
  • Implement the mutual exclusion primitives,
  • Use them in implementing a simple access control protocol

Instructions

Submit a single .zip file on blackboard with four folders, each containing the solutions to the below-specified parts.

For each function in the code, you need to write a piece of comment, describing its pre- and post-condition and a few test-cases.

Part 1: Yield

Restore Raspbian on Raspberry Pi.

Download the tiny threads library and run the sample program test1 using GCC on Linux. Notice that only one thread in the sample program gets to execute. This is so because there is no way of switching context: there is no invocation to yield() in the program and furthermore, there is no implementation for yield(). In this exercise you will implement the function

yield() 

in tinythreads.c. The function should


  • enqueue the current thread in the ready queue (as you can see in the source file tinythreads.c there are functions already implemented for enqueuing and dequeuing).
  • pick the first element in the queue, dequeue it and dispatch it! It is dispatch that makes the context-switch trick! (check the definition of dispatch).

Part 2: I/O on PiFace

Part 3: Train Controller

The final part of the assignment consists of implementing a sample of a train controller with two trains and a bridge.

Back to Embedded Systems Programming