atomicity

Guarantee unique global transaction for Kafka Producers

女生的网名这么多〃 提交于 2020-02-01 08:52:21
问题 With the last version of Kafka 0.11.0.0 the Apache team is introducing idempotent producer and transactions. Is It possible to guarantee that an entire set of messages (for example 1 million) we want to log, will be committed only at the end? I would like that, if for example the Producers loose the connection with the brokers and cannot restabilish it, no messages will be seen by the consumers. Is it possible? 回答1: Yes this is possible using Transactions in your producer. You start a

Why is acquire semantics only for reads, not writes? How can an LL/SC acquire CAS take a lock without the store reordering with the critical section?

只愿长相守 提交于 2020-01-22 16:36:06
问题 To start with, consider release semantics. If a data set is protected with a spinlock (mutex, etc. - no matters what exact implementation is used; for now, assume 0 means it's free and 1 - busy). After changing of the data set, a thread stores 0 to spinlock address. To force visibility of all previous actions before storing 0 to spinlock address, storing is executed with release semantics, that means all previous reads and writes shall be made visible to other threads before this storing. It

Java Atomicity & a good Compare and Swap framework?

半世苍凉 提交于 2020-01-06 03:07:15
问题 Do you guys think this is a good generic framework for atomic operations? Also do you think its correct to say With respect to Java applicatitions individual byte codes are atomic as there is no way of executing more than one byte code at a time with a single JVM? So if there was a single byte code for if else, then this if else instruction would be atomic? // CAS, Compare and Swap public abstract class CASOperation<T> { protected T valueAtStart; public CASOperation(){ valueAtStart =

Java Atomicity & a good Compare and Swap framework?

谁都会走 提交于 2020-01-06 03:06:09
问题 Do you guys think this is a good generic framework for atomic operations? Also do you think its correct to say With respect to Java applicatitions individual byte codes are atomic as there is no way of executing more than one byte code at a time with a single JVM? So if there was a single byte code for if else, then this if else instruction would be atomic? // CAS, Compare and Swap public abstract class CASOperation<T> { protected T valueAtStart; public CASOperation(){ valueAtStart =

Java Atomicity & a good Compare and Swap framework?

荒凉一梦 提交于 2020-01-06 03:06:05
问题 Do you guys think this is a good generic framework for atomic operations? Also do you think its correct to say With respect to Java applicatitions individual byte codes are atomic as there is no way of executing more than one byte code at a time with a single JVM? So if there was a single byte code for if else, then this if else instruction would be atomic? // CAS, Compare and Swap public abstract class CASOperation<T> { protected T valueAtStart; public CASOperation(){ valueAtStart =

Can atomic ops based spin lock's Unlock directly set the lock flag to zero?

拈花ヽ惹草 提交于 2020-01-05 02:48:13
问题 Say for example, I have an exclusive atomic-ops-based spin lock implementation as below: bool TryLock(volatile TInt32 * pFlag) { return !(AtomicOps::Exchange32(pFlag, 1) == 1); } void Lock (volatile TInt32 * pFlag) { while (AtomicOps::Exchange32(pFlag, 1) == 1) { AtomicOps::ThreadYield(); } } void Unlock (volatile TInt32 * pFlag) { *pFlag = 0; // is this ok? or here as well a atomicity is needed for load and store } Where AtomicOps::Exchange32 is implemented on windows using

Can atomic ops based spin lock's Unlock directly set the lock flag to zero?

故事扮演 提交于 2020-01-05 02:48:05
问题 Say for example, I have an exclusive atomic-ops-based spin lock implementation as below: bool TryLock(volatile TInt32 * pFlag) { return !(AtomicOps::Exchange32(pFlag, 1) == 1); } void Lock (volatile TInt32 * pFlag) { while (AtomicOps::Exchange32(pFlag, 1) == 1) { AtomicOps::ThreadYield(); } } void Unlock (volatile TInt32 * pFlag) { *pFlag = 0; // is this ok? or here as well a atomicity is needed for load and store } Where AtomicOps::Exchange32 is implemented on windows using

Interrupting an assembly instruction while it is operating

﹥>﹥吖頭↗ 提交于 2020-01-03 16:54:10
问题 When an interrupt comes to CPU, it is handled by saving current address location prior jumping into the handler if it is acknowledged. Otherwise it is ignored. I wonder whether an assembly instruction call is interrupted. For example, mvi a, 03h ; put 3 value into acc. in 8080 assembly Can be the one line instruction interrupted? Or if not, it is atomic?? Is there always a guarantee that "one line assembly instruction" is always atomic?? What if there is no "lock" keyword i.e. in 8080

Atomic read and write of long and double values

依然范特西╮ 提交于 2020-01-02 02:33:06
问题 long and double read and write operation are not atomic because of their size more than cpu word size. So could I get atomic read and write operation of long and double if I have 64 bit machine? 回答1: so could i get atomic read and write operation of long and double if i have 64 bit machine ? The answer is "maybe". The answer depends on the JVM implementation as well as the machine architecture. To quote from the Java Language definition 17.7: Some implementations may find it convenient to

is sql server transaction atomic

你说的曾经没有我的故事 提交于 2020-01-01 05:16:16
问题 so I have a stored procedure (sql server 2008 r2) something like this BEGIN TRAN BEGIN TRY //critical section select value update value //end of critical section COMMIT END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK END CATCH I want no two stored procedures read the same value. In other words read and update should be atomic. This code does this? If not how do I do it? 回答1: Yes they are atomic but that does not mean that you will get the behaviour that you want here! The property you need to