Wiki Page Content

Differences between revisions 7 and 8
Revision 7 as of 2011-01-28 20:20:57
Size: 1139
Editor: SheenaSmith
Comment: correct typo
Revision 8 as of 2011-02-02 18:15:42
Size: 622
Editor: SheenaSmith
Comment: update content - w/ Sam; remove draft
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
Line 16: Line 15:
||'''lock'''||,,points to the lock,, ^the desired SDL_!SpinLock to lock^||

<<Color2(green,Should SDL_!SpinLock be changed to spin lock because it's a typedef with no page? Does this function change the setting of a lock struct (typedef?) to non-0 automatically when it is called? Unlock changes it back to 0?)>>
||'''lock'''||a pointer to a lock variable||
Line 26: Line 23:
The spin lock functions and type are required and can not be emulated because they are used in the emulation code.

<<Color2(green,Would the following site be a relevant link here or perhaps in a more detailed section on this topic?)>>
http://en.wikipedia.org/wiki/Spin_lock
<<Include(CategoryAtomic, , , from="Start include here.", to="##The Include ends here")>>

SDL_AtomicLock

Use this function to lock a spin lock by setting it to a non-zero value.

Syntax

void SDL_AtomicLock(SDL_SpinLock* lock)

Function Parameters

lock

a pointer to a lock variable

Code Examples

You can add your code example here

Remarks

Include: Nothing found for "Start include here."!

Include: Nothing found for "##The Include ends here"!

Atomic Operations

Include File(s): SDL_atomic.h

Introduction

This category contains functions for handling atomic operations.

/!\ IMPORTANT:

  • If you are not an expert in concurrent lockless programming, you should only be using the atomic lock and reference counting functions in this file. In all other cases you should be protecting your data structures with full mutexes. Seriously, here be dragons!

"Safe" functions to use are:

You can find out a little more about lockless programming and the subtle issues that can arise here:

There's also lots of good information here:

These operations may or may not actually be implemented using processor specific atomic operations. When possible they are implemented as true processor specific atomic operations. When that is not possible the are implemented using locks that do use the available atomic operations.

All of the atomic operations that modify memory are full memory barriers.

Atomic Locks

The atomic locks are efficient spinlocks using CPU instructions, but are vulnerable to starvation and can spin forever if a thread holding a lock has been terminated. For this reason you should minimize the code executed inside an atomic lock and never do expensive things like API or system calls while holding them.

/!\ The atomic locks are not safe to lock recursively.

Structures

Functions


CategoryCategory


CategoryAPI, CategoryAtomic

None: SDL_AtomicLock (last edited 2011-02-02 18:18:28 by SheenaSmith)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit