EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #163 background imageLoading...
Page #163 background image
Semaphores
Thread Scheduling 4-59
4.7 Semaphores
DSP/BIOS provides a fundamental set of functions for intertask
synchronization and communication based upon semaphores. Semaphores
are often used to coordinate access to a shared resource among a set of
competing tasks. The SEM module provides functions that manipulate
semaphore objects accessed through handles of type SEM_Handle.
SEM objects are counting semaphores that can be used for both task
synchronization and mutual exclusion. Counting semaphores keep an
internal count of the number of corresponding resources available. When
count is greater than 0, tasks do not block when acquiring a semaphore.
The functions SEM_create and SEM_delete are used to create and delete
semaphore objects, respectively, as shown in Example 4-8. You can also
create semaphore objects statically. See Section 2.4, Creating DSP/BIOS
Objects Dynamically, page 2-16, for a discussion of the benefits of creating
objects statically.
Example 4-8. Creating and Deleting a Semaphore
The semaphore count is initialized to count when it is created. In general,
count is set to the number of resources that the semaphore is synchronizing.
SEM_pend waits for a semaphore. If the semaphore count is greater than 0,
SEM_pend simply decrements the count and returns. Otherwise, SEM_pend
waits for the semaphore to be posted by SEM_post.
Note:
When called within an HWI, the code sequence calling SEM_post or
SEM_ipost must be either wrapped within an HWI_enter/HWI_exit pair or
invoked by the HWI dispatcher.
The timeout parameter to SEM_pend, as shown in Example 4-9, allows the
task to wait until a timeout, to wait indefinitely (SYS_FOREVER), or to not
wait at all (0). SEM_pend’s return value is used to indicate if the semaphore
was acquired successfully.
SEM_Handle SEM_create(count, attrs);
Uns count;
SEM_Attrs *attrs;
Void SEM_delete(sem);
SEM_Handle sem;

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals