Huawei launched the World's smallest operating-level Router Atom Router at the Mobile World Congress 2014 today ). This atomic router can be deployed on any node or device on the current network, and can be visualized and managed without modifying the current network, provides high-precision Performance Detection for each user and business in real time, helping traditional networks increase network value. This major breakthrough focusing on customer n
modify the status of any program. This is why constant and atomic data are recommended at the same time. Break down your object into a natural single entity structure. An address is a simple task. It consists of multiple related fields. Changing one of the fields may mean modifying other fields. A customer type is not an atomic type. A customer type may contain many small information blocks: addresses, nam
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
()
{
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
Atomicinteger can guarantee that the operation of an integral type is atomic. Like i++ This operation is not atomic operation, there is a race condition, so need to lock, but the performance of locking is not high, if only to add 1 to an integer. Let's look at his realization. private volatile int value;The Atomicinteger itself holds an integer variable, and all operations are based on that variable. The
ObjectiveFor Java multithreading, there is no more contact than using synchronized, which is easy to understand, but this synchronized is not the best performance. Today I will briefly introduce several kinds of locks. Maybe I'm talking about a lot of things will not be particularly profound, the best way is to do their own experiments, the various scenarios in the code to experiment, so the hair found a lot of details.VolatileAs a lightweight lock in Java, when one thread in a multi-threaded op
Scene:1. When multithreaded programming, it is sometimes necessary to count the number of times a variable or object is created, or whether it is necessary to continue execution depending on the value of a variable, which is one of the more efficient schemes for the Interlock function.Description1. Atomic access: (Interlock function family)--atomic access, which means that threads can access resources to en
Singleton mode is one of 23 design patterns, about its introduction, has been countless, the general online implementation of the way is nothing but what lazy type, a hungry man type, internal class, enumeration, volatile plus double check lock and so on, today I think of a new way of realization, Using the atomic class provided by J.U.C, the code is as follows:class SingleTon { privatestaticnew AtomicReferenceprivateSingleTon() { } publicsta
Label: style Io ar strong Div SP on C Ad I ++ is divided into three phases: Memory to registerRegister auto-IncrementWrite back memoryAll three stages can be interrupted and separated. I ++ executes 100 times in two threads respectively. What are the maximum and minimum values? I ++ only needs to execute one command and cannot guarantee that multiple threads I ++ can operate on the same I to get the correct result. Because of the Register, multiple CPUs correspond to multiple registers. It t
[Date: 2011-06-17]
Source: Linux community Author: franktan
GCC provides the _ sync _ * series of built-in functions 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_a
First look at the test code
// cas.c#include
// spinlock.c#include
// mutex.c #include
Result:
# time ./mutex 10000000real 0m0.235suser 0m0.040ssys 0m0.000s# time ./spinlock 10000000real 0m0.111suser 0m0.010ssys 0m0.010s# time ./cas 10000000real 0m0.083suser 0m0.010ssys 0m0.000s
More gcc-provided atomic operation reference http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/
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.