Nonatomic: Non-atomic access, no lock when assigning values to attributes, multi-thread concurrent access will improve performance. If this attribute is not added, both access methods are atomic transaction access by default.
(Atomic is a thread protection technology used by objc. Basically, it is used to prevent reading by another thread when the write is not co
Done twiceCodeBoth Java and. Net were reviewed for about three hours. The biggest achievement is to separate the scheduling method from the atomic operation method.
The scheduling method is generally a method that calls other methods to implement a function based on different situations.
The scheduling method reflects the process.
The atomic operation method is generally a method with a single func
This is part of the interlocked API introduced by Microsoft, but the atomic operation problem is mentioned in it. Although it should be only for Microsoft operating systems, I think all operating systems should be consistent. For a numeric operation that has the same or lower CPU bits and is aligned with bytes, the value assignment must be completed. After the assignment, the value must be assigned, after the value is obtained, it must be a value assi
1. Introduction
Atom is intended to be "the smallest particle that cannot be further divided", and atomic operation is "one or more operations that cannot be interrupted ". It is a little complicated to implement atomic operations on a multi-processor. In this article, let's talk about how the Intel processor and Java implement atomic operations.2. Definition of
variable simultaneously using CAS, only one of the threads can update the value of the variable, and the other threads will fail. * However, the failed thread is not suspended, but is told to fail in this competition and can try again. * Because a thread does not block when it competes with CAS, it can decide whether to retry, or perform some recovery operations, or not take any action. */ Public classSimulatedcas {Private intvalue; Public synchronized intget () {returnvalue; } Public
Ext.: http://www.blogjava.net/xylz/archive/2010/07/01/324988.htmlStart with a relatively simple atomic (Java.util.concurrent is a queue-based contract and the queue, in many cases, uses the atomic operation, so begin here first). In many cases we just need a simple, efficient, thread-safe increment-decrement scheme. Note that there are three conditions: simple, which means that it is easier for programmers
The Java class library contains a number of useful "base module" classes. In general, we should prefer to reuse these existing classes instead of creating new ones. : Reuse can reduce development effort, develop risk (because existing classes are already tested), and maintenance costs. Sometimes, a thread-safe class can support all the operations we need, but more often, the existing class can only support most operations, and a new operation needs to be added without breaking the thread's secur
I haven't written any learning logs for a long time, and I don't know what I 've been busy with recently. I suddenly felt I should write something.
The database's atomic operation was learned two or three months ago. It was suddenly used again today, so it must be recorded today, or it will be searched again next time.
A common method for atomic operations is to implement data rollback. Using PHP to impleme
Import java. util. concurrent. atomic. atomicInteger; public class Counter {public static int count = 0; public static volatile int volatileCount = 0; public static AtomicInteger atomicCount = new AtomicInteger (0 ); public static byte [] lock = new byte [0]; public static int syCount = 0; public static void sleep (final int gap) {try {Thread. sleep (gap);} catch (InterruptedException e) {// TODO Auto-generated catch blocke. printStackTrace () ;}} pub
(); int next = current-1; if (Compareandset (current, next)) return next; }} public final int addandget (int. delta) {for (;;) {int current = get (); int next = current + Delta; if (Compareandset (current, next)) return next; }} public String toString () {return integer.tostring (get ()); } public int Intvalue () {return get (); } public Long Longvalue () {return (long) get (); } public float Floatvalue () {return (float) get (); } p
CAS operations can be divided into the following three steps:
Step 1. Read the old value (that is, the value of the variable to be read from system memory, for example: reading the value of the variable i)
Step 2. Novelty value (that is, the value read from memory operation, but the operation does not modify the value of the variable in memory, such as: i=i+1, this step is only i+1, no assignment, do not modify the memory i)
Step 3. Two indivisible atomic
Tags: API block different SDN NET detail logs image caseBecause of the working relationship, there has recently been something related to the ADF (Atomic Display Framework), some of it comes from the internetThe ADF (Atomic display framework) is Google's new display framework to replace Framebuffer. ADF provides a DMA-BUF-based display framework prototype between the Android Hwcomposer Hal and the kernel dr
This article posts the ISO image files of common Server versions in RHEL (RedHat Enterprise Linux) for you to download and use. The released versions include RedHat Enterprise Linux (RHEL) 5.4/5.5/5.8/6.0/6.3 ISO image file:RHEL 5.4 ISO downloadHttp://rhel.ieesee.net/uingei/rhel-server-5.4-i386-dvd.iso
Http://rhel.ieesee.net/uingei/
This article has posted an ISO image of the server version that is commonly used in the release of RHEL (RedHat Enterprise Linux) for everyone to download and use, and the posted version has RedHat Enterprise Linux (RHEL) 5.4/5.5/5.8/ 6.0/6.3 ISO image file:RHEL 5.4 iso DownloadHttp://rhel.ieesee.net/uingei/rhel-server-5.4-i386-dvd.isoHttp://rhel.ieesee.net/uinge
Version has Redhat Enterprise Linux (RHEL) 5.4/5.5/5.8/6.0/6.3 iso image file download address:
RHEL 5.4 iso Download
Http://rhel.ieesee.net/uingei/rhel-server-5.4-i386-dvd.iso
Http://rhel.ieesee.net/uingei/rhel-server-5.4-x86_64-dvd.iso
RHEL 5.5 ISO Download
Http://mirr
()
{
G_nlogincount = 0;
HANDLE Handle[thread_num];
For (int i = 0; i
Handle[i] = (handle) _beginthreadex (null, 0, threadfun, NULL, 0, NULL);
WaitForMultipleObjects (Thread_num, handle, TRUE, INFINITE);
printf ("%d users log results after logging%d\n", Thread_num, G_nlogincount);
return 0;
}
The program simulates the user Login, the program will output the results: As with the previous thread-count program, the output of the program seems to have no problem. Bel
Atomic variable analysis in Linux Kernel
There are several things in the Linux kernel that are common, and atomic variables are one of them. In fact, I have never tried these things before. After all, there are just a few lines of code, as long as I know what this means. It is limited to knowing that there is an assembly command called lock. This ensures the atomicity of data operations. But a few days ago,
Quoted from: http://blog.csdn.net/lizhibin1091666592/article/details/6976254
A basic principle of the kernel is that in the interrupt or atomic context, the kernel cannot access user space, and the kernel cannot sleep. That is to say, in this case, the kernel cannot call any function that may cause sleep. Generally, the atomic context refers to the interruption or soft interruption, and the holding of the s
The atomic operation of integers, for the atomic_t type, has always been mentioned in the book that the CPU architecture itself supports simple atomic operations, or provides the function of locking the memory bus, you can prevent data access during the operation.
Today, we suddenly thought that the ARM architecture itself does not provide the lock memory bus function, and there are no commands similar to
Reprint Address: http://www.cnblogs.com/FrankTan/archive/2010/12/11/1903377.htmlGCC provides the built-in function of the __sync_* series from 4.1.2 to provide atomic operations for addition and subtraction and logical operations.The statement is as follows:type __sync_fetch_and_add (type *ptr, type value, ...)type __sync_fetch_and_sub (type *ptr, type value, ...)type __sync_fetch_and_or (type *ptr, type value, ...)type __sync_fetch_and_and (type *ptr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.