tobudos-kernel/Project/Linux_Posix/mutex
tensfile 4a6a44681f add mutex example 2024-07-03 00:29:12 +08:00
..
inc add mutex example 2024-07-03 00:29:12 +08:00
src add mutex example 2024-07-03 00:29:12 +08:00
CMakeLists.txt add mutex example 2024-07-03 00:29:12 +08:00
Makefile add mutex example 2024-07-03 00:29:12 +08:00
README.md add mutex example 2024-07-03 00:29:12 +08:00

README.md

Mutex Example

This example shows how to use the mutex in TobudOS. The example creates two tasks, each of which increments the shared variable counter. To avoid race conditions, the example uses mutex api to protect the shared resource. The output of the example is

Task task1: Counter is 1
Task task2: Counter is 2
Task task2: Counter is 3
Task task1: Counter is 4
Task task1: Counter is 5

step1

make sure your develop environment.

  • cmake and version greater than 3.8.2
  • gcc gdb make is installed

step2

make build directory and compile in build

mkdir build && cd build
cmake ..
make

step3

run program !!

# in build directory
./mutex

other

you can copy this demo to other path, but if you want do it, you need modify CMakeLists.txt. find line

set(TINY_ROOT ../../../)

and modify path-to-tinyos

set(TINY_ROOT path-to-tinyos)