From f868d520a73da31f87c1fc637d1f650148b28b8b Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 20 May 2010 07:23:05 -0400 Subject: [PATCH] Added atomic and per-cpu. --- 07concurrency/concurrency | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/07concurrency/concurrency b/07concurrency/concurrency index afbd041..43815d6 100644 --- a/07concurrency/concurrency +++ b/07concurrency/concurrency @@ -97,4 +97,36 @@ the critical section at a time. * They create an atomic context themselves, so *do not* sleep while using them +# Atomic + +* atomic\\_t +* ATOMIC\\_INIT(val) +* atomic\\_read(v) +* atomic\\_set(v, i) +* atomic\\_add\\_return(i, &v) +* atomic\\_add(i, &v) +* atomic\\_inc(i, &v) +* atomic\\_sub +* atomic\\_dec +* atomic\\_dec\\_and\\_test + +# Bitmap + +May be used for locking, but spinlocks are better nowadays. + +# Per-CPU + +* linux/percpu.h +* DEFINE\\_PER\\_CPU(type, name) +* get\\_cpu\\_var(name) +* put\\_cpu\\_var(name) +* per\\_cpu(name, cpu) +* alloc\\_percpu(type) +* free\\_percpu +* cpu = get\\_cpu() +* per\\_cpu\\_ptr(var, cpu) +* put\\_cpu() + +# RCU + -- 2.20.1