Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Скажите пожалуйста, а как в принципе можно гарантировать пункт номер 5
Есть ещё у меня репозиторий, где собираю ссылки на работы
Да-да, помимо пачки отличных программных продуктов (OpenSolaris, MySQL, OpenOffice) Oracle забросила и перспективную аппаратную технологию
и алгоритмы с использованием транзакций писать проще
# define LLL_MUTEX_LOCK_ELISION(mutex) \
lll_lock_elision ((mutex)->__data.__lock, (mutex)->__data.__elision, \
PTHREAD_MUTEX_PSHARED (mutex))
int
__pthread_mutex_lock (mutex)
pthread_mutex_t *mutex;
{
/* code */
return LLL_MUTEX_LOCK_ELISION (mutex);
/* code */
return 0;
}
#define lll_lock_elision(futex, adapt_count, private) \
__lll_lock_elision (&(futex), &(adapt_count), private)
/* Adaptive lock using transactions.
By default the lock region is run as a transaction, and when it
aborts or the lock is busy the lock adapts itself. */
int
__lll_lock_elision (int *futex, short *adapt_count, EXTRAARG int private)
{
if (*adapt_count <= 0)
{
unsigned status;
int try_xbegin;
for (try_xbegin = aconf.retry_try_xbegin;
try_xbegin > 0;
try_xbegin--)
{
if ((status = _xbegin()) == _XBEGIN_STARTED)
{
if (*futex == 0)
return 0;
/* Lock was busy. Fall back to normal locking.
Could also _xend here but xabort with 0xff code
is more visible in the profiler. */
_xabort (_ABORT_LOCK_BUSY);
}
if (!(status & _XABORT_RETRY))
{
if ((status & _XABORT_EXPLICIT)
&& _XABORT_CODE (status) == _ABORT_LOCK_BUSY)
{
/* Right now we skip here. Better would be to wait a bit
and retry. This likely needs some spinning. */
if (*adapt_count != aconf.skip_lock_busy)
*adapt_count = aconf.skip_lock_busy;
}
/* Internal abort. There is no chance for retry.
Use the normal locking and next time use lock.
Be careful to avoid writing to the lock. */
else if (*adapt_count != aconf.skip_lock_internal_abort)
*adapt_count = aconf.skip_lock_internal_abort;
break;
}
}
}
else
{
/* Use a normal lock until the threshold counter runs out.
Lost updates possible. */
(*adapt_count)--;
}
/* Use a normal lock here. */
return LLL_LOCK ((*futex), private);
}
hist_updater (void * data)
{
int D.4096;
int D.4095;
unsigned int D.4094;
unsigned int luminance;
struct pixel p;
struct data * d;
size_t i;
void * D.4098;
long unsigned int D.4097;
double D.4093;
double D.4092;
double bY.2;
double D.4090;
int D.4089;
unsigned char D.4088;
double D.4087;
double D.4086;
double gY.1;
double D.4084;
int D.4083;
unsigned char D.4082;
double D.4081;
double rY.0;
double D.4079;
int D.4078;
unsigned char D.4077;
struct pixel * D.4076;
long unsigned int D.4075;
struct pixel * D.4074;
d = data;
i = 0;
goto <D.3999>;
<D.3998>:
try
{
D.4074 = d->pixels;
D.4075 = i * 3;
D.4076 = D.4074 + D.4075;
p = *D.4076;
D.4077 = p.red;
D.4078 = (int) D.4077;
D.4079 = (double) D.4078;
rY.0 = 2.1260000000000001119104808822157792747020721435546875e-1;
D.4081 = D.4079 * rY.0;
D.4082 = p.green;
D.4083 = (int) D.4082;
D.4084 = (double) D.4083;
gY.1 = 7.1519999999999994688693050193251110613346099853515625e-1;
D.4086 = D.4084 * gY.1;
D.4087 = D.4081 + D.4086;
D.4088 = p.blue;
D.4089 = (int) D.4088;
D.4090 = (double) D.4089;
bY.2 = 7.220000000000000028865798640254070051014423370361328125e-2;
D.4092 = D.4090 * bY.2;
D.4093 = D.4087 + D.4092;
luminance = (unsigned int) D.4093;
luminance = luminance + 1;
__transaction_atomic // SUBCODE=[ GTMA_HAVE_LOAD GTMA_HAVE_STORE ]
try
{
D.4094 = luminance / 16;
D.4095 = histogram[D.4094];
D.4096 = D.4095 + 1;
histogram[D.4094] = D.4096;
}
finally
{
__builtin__ITM_commitTransaction ();
}
}
finally
{
p = {CLOBBER};
}
i = i + 1;
<D.3999>:
D.4097 = d->sz;
if (D.4097 > i) goto <D.3998>; else goto <D.4000>;
<D.4000>:
free (d);
D.4098 = 0B;
goto <D.4099>;
<D.4099>:
return D.4098;
}
hist_updater (void * data)
{
unsigned int luminance;
struct pixel p;
long unsigned int D.4097;
int D.4096;
int D.4095;
unsigned int D.4094;
double D.4093;
double D.4092;
double bY.2;
double D.4090;
int D.4089;
unsigned char D.4088;
double D.4087;
double D.4086;
double gY.1;
double D.4084;
int D.4083;
unsigned char D.4082;
double D.4081;
double rY.0;
double D.4079;
int D.4078;
unsigned char D.4077;
struct pixel * D.4076;
long unsigned int D.4075;
struct pixel * D.4074;
struct data * d;
size_t i;
void * D.4098;
d = data;
__transaction_atomic // SUBCODE=[ GTMA_HAVE_LOAD GTMA_HAVE_STORE ]
try
{
i = 0;
goto <D.3999>;
<D.3998>:
try
{
D.4074 = d->pixels;
D.4075 = i * 3;
D.4076 = D.4074 + D.4075;
p = *D.4076;
D.4077 = p.red;
D.4078 = (int) D.4077;
D.4079 = (double) D.4078;
rY.0 = 2.1260000000000001119104808822157792747020721435546875e-1;
D.4081 = D.4079 * rY.0;
D.4082 = p.green;
D.4083 = (int) D.4082;
D.4084 = (double) D.4083;
gY.1 = 7.1519999999999994688693050193251110613346099853515625e-1;
D.4086 = D.4084 * gY.1;
D.4087 = D.4081 + D.4086;
D.4088 = p.blue;
D.4089 = (int) D.4088;
D.4090 = (double) D.4089;
bY.2 = 7.220000000000000028865798640254070051014423370361328125e-2;
D.4092 = D.4090 * bY.2;
D.4093 = D.4087 + D.4092;
luminance = (unsigned int) D.4093;
luminance = luminance + 1;
D.4094 = luminance / 16;
D.4095 = histogram[D.4094];
D.4096 = D.4095 + 1;
histogram[D.4094] = D.4096;
}
finally
{
p = {CLOBBER};
}
i = i + 1;
<D.3999>:
D.4097 = d->sz;
if (D.4097 > i) goto <D.3998>; else goto <D.4000>;
<D.4000>:
}
finally
{
__builtin__ITM_commitTransaction ();
}
free (d);
D.4098 = 0B;
goto <D.4099>;
<D.4099>:
return D.4098;
}


Транзакционная память: история и развитие