Re: applying atomic assignment in which situation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Aug 9, 2010 at 6:15 AM, Parmenides <mobile.parmenides@xxxxxxxxx> wrote:
> Hi,
>
>   In the following code excerpt of kernel, why the 'count' field is
> set by atomic_set while other fields of tha same structure can take an
> assignment directly?

It depends on how the variables are used.

> void tasklet_init(struct tasklet_struct *t,
>                  void (*func)(unsigned long), unsigned long data)
> {
>        t->func = func;
>        t->data = data;
>        t->state = 0;
>        atomic_set(&t->count, 0);
> }
>
> Furthermore, the definition of atomic_set is as follows
>
> #define atomic_set(v,i)         (((v)->counter) = (i))
>
> and there is seemingly no 'atomic feature' at all.

This is pretty typical for set, when the size of the atomic variable
matches the processor's "natural" width.

Much more interesting is to look at an atomic increment, or an atomic
test and swap.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux