Ejemplo n.º 1
0
void increment() {
	type res = __hle_acquire_test_and_set4(&lock);
	while (res == 1) { // wait until lock was not locked
		_mm_pause();
//		__asm volatile ("pause" ::: "memory");
		res = __hle_acquire_test_and_set4(&lock);
	}
//	printf("Acquired Lock: %d  |  i: %d\n", lock, i);

	usleep(1); // provoke an error
	i++;

	__hle_release_clear4(&lock);
//	printf("Released Lock: %d  |  i: %d\n", lock, i);
}
Ejemplo n.º 2
0
void test_abortion() {
	while (true) {
		int test = 0;
		unsigned lockVal = 0;
		unsigned * lock = &lockVal;

		__hle_acquire_exchange_n4(lock, 1);

		test = 1;
		_mm_pause();

		__hle_release_clear4(lock);

		printf("Test: %d\n", test);
		// 100% Transaction aborts
		// BUT
		// test is 1 after this
		// therefore, hle fell back to do a manual mutex lock
	}
}
Ejemplo n.º 3
0
void release_hle(unsigned int* lock)
{
        __hle_release_clear4(lock);
}