The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
x86.c File Reference

x86 synchronization primitives More...

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <arch/atomic.h>
#include <mm/dymelor.h>
+ Include dependency graph for x86.c:

Go to the source code of this file.

Functions

bool iCAS (volatile uint32_t *ptr, uint32_t oldVal, uint32_t newVal)
 
int atomic_test_and_set (int *b)
 
void atomic_inc (atomic_t *v)
 
void atomic_dec (atomic_t *v)
 
int atomic_inc_and_test (atomic_t *v)
 
void spin_lock (spinlock_t *s)
 
bool spin_trylock (spinlock_t *s)
 
void spin_unlock (spinlock_t *s)
 

Detailed Description

x86 synchronization primitives

This module implements atomic and non-blocking operations used within ROOT-Sim to coordinate threads and processes (on shared memory)

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Alessandro Pellegrini
Date
Jan 25, 2012

Definition in file x86.c.

Function Documentation

void atomic_dec ( atomic_t v)
inline

This function implements (on x86-64 architectures) the atomic dec operation. It decrements the atomic counter 'v' by 1 unit

Parameters
vthe atomic counter which is the destination of the operation

Definition at line 103 of file x86.c.

+ Here is the caller graph for this function:

void atomic_inc ( atomic_t v)
inline

This function implements (on x86-64 architectures) the atomic inc operation. It increments the atomic counter 'v' by 1 unit

Parameters
vthe atomic counter which is the destination of the operation

Definition at line 90 of file x86.c.

+ Here is the caller graph for this function:

int atomic_inc_and_test ( atomic_t v)
inline

This function implements (on x86-64 architectures) the atomic dec operation. It decrements the atomic counter 'v' by 1 unit

Parameters
vthe atomic counter which is the destination of the operation
Returns
true if the counter became zero

Definition at line 118 of file x86.c.

+ Here is the caller graph for this function:

int atomic_test_and_set ( int *  b)
inline

This function implements the atomic_test_and_set on an integer value, for x86-64 archs

Parameters
bthe counter there to perform the operation
Returns
true if the int value has been set, false otherwise

Definition at line 71 of file x86.c.

+ Here is the caller graph for this function:

bool iCAS ( volatile uint32_t *  ptr,
uint32_t  oldVal,
uint32_t  newVal 
)
inline

This function implements a compare-and-swap atomic operation on x86-64 for integers

Parameters
ptrthe address where to perform the CAS operation on
oldValthe old value we expect to find before swapping
newValthe new value to place in ptr if ptr contains oldVal
Returns
true if the CAS succeeded, false otherwise

Definition at line 49 of file x86.c.

+ Here is the caller graph for this function:

void spin_lock ( spinlock_t s)
inline

This function implements (on x86-64 architectures) a spinlock operation.

Parameters
sthe spinlock on which to spin

Definition at line 135 of file x86.c.

+ Here is the caller graph for this function:

bool spin_trylock ( spinlock_t s)
inline

This function implements (on x86-64 architectures) a trylock operation.

Parameters
sthe spinlock to try to acquire

Definition at line 151 of file x86.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void spin_unlock ( spinlock_t s)
inline

This function implements (on x86-64 architectures) a spin unlock operation.

Parameters
sthe spinlock to unlock

Definition at line 161 of file x86.c.

+ Here is the caller graph for this function: