Starting from:

$30

EMBSYS105-Assignment 2 ContextSwitch Solved

The goal of this assignment is to gain understanding of context switching by writing context switch code in assembly language.

1.      Download and unzip the ContextSwitch project contained in the zip file: ContextSwitch.zip

2.      Open the ContextSwitch.eww workspace in the EWARM IDE.

3.      Make sure the ContextSwitch project builds.

4.      Launch TeraTerm (38400 Baud rate)

5.      Build and upload the project and start it running.

6.      Break into the program to stop the output stream on the UART.

7.      Notice it is printing an endless stream of messages from task one like this:

     University of Washington - Context Switch Application task one: 0 task one: 1 task one: 2 task one: 3

...
8.      Implement the context switch code specified by the comments in switch.s.

9.      When completed correctly you should see output in the UART from both task one and task two as the context switches at every clock tick.



ContextSwitch_<YourUwNetId.zip



Optional Additional challenge!

Those looking for an additional challenge may want to implement testAndSet(). Implement it in assembly language using LDREX and STREX. Call it in the C code of each task to protect access to the UART so each task can print an entire line without interference. You may want to remove the print statement in the scheduler routine.

More products