3 Semaphores Flashcards

1
Q

What are the advantages of task synchronisation?

A

Task Synchronisation makes it possible for tasks to co-ordinate and co-operate.
Can be used to communicate between tasks.
Can be used to protect shared data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the types of semaphores

A

Binary, counting, and mutex

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe binary semaphores

A

Binary - Implements synchronisation between tasks or between interrupt handlers and tasks. An attempt to take a semaphore will block unless the semaphore has been given by another task or interrupt handler.
Can be given infinite times but only taken once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe counting semaphores

A

Counting- Has a count variable associated with it.
Giving the semaphore increments the count
Taking the semaphore decrements the count
Can be used for counting events to ensure that no events lost.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe a mutex

A

Mutex – Token used to guard a resource.
Only the task with mutex can access the resource.
When a mutex is taken, it must be given back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you create a binary semaphore?

A

Define a variable of type SemaphoreHandle_t
SemaphoreHandle_t SW_Semaphore=NULL;,
SW_Semaphore = xSemaphoreCreateBinary();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you give or take a semaphore?

A

xSeamphoreGive() and xSemaphoreTake()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a deadlock?

A

A deadlock is where 2 tasks cannot proceed because they are both waiting on a resource held by the other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly