Motorola MCP750 Specifications Page 137

  • Download
  • Add to my manuals
  • Print
  • Page
    / 344
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 136
Understanding the Kernel Environmen
t
9-1
7
Synchronization Routines 9
The kernel provides three broad categories of synchronization/serialization routines: spin
locks, sleep locks, and event synchronization primitives. These routines are used to main-
tain data integrity in the system by serializing process access to shared resources and by
synchronizing processes. The routines associated with each category are presented in the
sections that follow. Guidelines for using these routines are provided in Chapter 11 (“Mul-
tithreading a Device Driver”).
Spin Locks 9
Spin locks are low-level, busy-waiting primitives. They are used to serialize access to
shared resources when blocking primitives cannot be used (at interrupt level, for example)
and when the expected wait time is very short. Spin locks are of two types: basic spin
locks and read/write spin locks.
Basic locks allow only one process to gain access to a shared resource at a time. The basic
lock routines are as follows:
LOCK(D3) Acquire a basic lock
LOCK_ALLOC(D3) Allocate and initialize a basic lock
LOCK_DEALLOC(D3) Deallocate an instance of a basic lock
TRYLOCK(D3) Try to acquire a basic lock
UNLOCK(D3) Release a basic lock
Read/write locks allow you to distinguish between readers and writers when controlling
access to shared resources. Multiple processes can simultaneously obtain a lock in read
mode. Only one process can obtain a lock in write mode. A lock is available in read mode
if it is idle or it is held by one or more readers and there are no waiting writers. A lock is
available in write mode only if it is idle.
The read/write lock routines are as follows:
RW_ALLOC(D3) Allocate and initialize a read/write lock
RW_DEALLOC(D3) Deallocate an instance of a read/write lock
RW_RDLOCK(D3) Acquire a read/write lock in read mode
RW_WRLOCK(D3) Acquire a read/write lock in write mode
RW_TRYRDLOCK(D3) Try to acquire a read/write lock in read mode
RW_TRYWRLOCK(D3) Try to acquire a read/write lock in write mode
RW_UNLOCK(D3) Release a read/write lock
Page view 136
1 2 ... 132 133 134 135 136 137 138 139 140 141 142 ... 343 344

Comments to this Manuals

No comments