RE: applying atomic assignment in which situation

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

 



Posting again since seems that my email box is not working properly.

 


From: Castillo Fuentes, David
Sent: Monday, August 09, 2010 9:56 AM
To: 'Parmenides'; kernelnewbies@xxxxxxxxxxxx
Subject: RE: applying atomic assignment in which situation

 

Hi,

 

You know, the most important point of doing variables atomic is to avoid race conditions when writing simple variables/Entities in a Multithreading code, but you are right in the macro definition you mentioned below, which doesn’t appear to be atomic at all.

 

You know, the best way of doing things atomic in a Linux env. It’s to make variables “volatile” in other words.

 

Regards

Avi

 

-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Parmenides
Sent: Monday, August 09, 2010 8:15 AM
To: kernelnewbies@xxxxxxxxxxxx
Subject: applying atomic assignment in which situation

 

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?

 

void tasklet_init(struct tasklet_struct *t,

                  void (*func)(unsigned long), unsigned long data)

{

        t->func = func;

        t->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.

 

--

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