volatile

Non-volatile UDF always recalculating

浪尽此生 提交于 2019-12-03 03:33:36
I am trying to make a non-volatile UDF but it seems not possible. So here is a my very simple test-UDF: Option Explicit Dim i As Integer Sub Main() i = 0 [A1] = "zyy" MsgBox i End Sub Function Test(rng As Range) Application.Volatile (False) Test = rng.Value i = i + 1 End Function I got a otherwise empty worksheet that uses this function a couple of times, and every time I call Main() and change any cell on the sheet with the UDFs all of them recalculate. How can I make this (any) UDF no-volatile? The Application.Volatile (False) should have that effect but obviously doesn't work. Edit: If I

Pointer declared as constant as well as volatile

北慕城南 提交于 2019-12-03 03:29:18
问题 While reading I came across this type of declaration and the following line - const volatile char *p=(const volatile char *) 0x30; The value of p is changed by external conditions only I don't get what are the external conditions . And also what is practical use of this type of declaration ? 回答1: The const says that the flow of your program isn't going to modify what is pointed to by p . Any attempt to modify the value after dereferencing the pointer will result in a compile-time error: *p =

Volatile keyword in Java - Clarification [duplicate]

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Difference between volatile and synchronized in Java 4 answers I am really confused about what I read about the applications of volatile keyword in java. Is the following statement correct? "a write to a volatile field happens before every subsequent read of the same field" Ideally when should volatile keyword used? What is the difference between: class TestClass { private int x; synchronized int get(){return x;} synchronized void set(int x){this.x = x;} } and class TestClass { private volatile int x

Java: volatile enough to make classes threadsafe?

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a question about the volatile statement in Java. Please look at this constructed example: class Master { // Foo is a class with thread-safe methods public volatile Foo foo; } class Worker1 implements Runnable { protected Master master void run() { ... }; } class Worker2 implements Runnable { protected Master master void run() { ... }; } We have 2 worker threads which hold a reference to an object of class Master running at the same time. During their work, both have to access methods of master.foo. At some point, the Foo object of

The volatile key word and memory consistency errors

匿名 (未验证) 提交于 2019-12-03 03:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In the oracle Java documentation located here , the following is said: Atomic actions cannot be interleaved, so they can be used without fear of thread interference. However, this does not eliminate all need to synchronize atomic actions, because memory consistency errors are still possible. Using volatile variables reduces the risk of memory consistency errors, because any write to a volatile variable establishes a happens-before relationship with subsequent reads of that same variable. This means that changes to a volatile variable are

Does an EventWaitHandle have any implicit MemoryBarrier?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: New to this website, so let me know if I'm not posting in an accepted manner. I've frequently coded something along the lines of the sample below(with stuff like Dispose ommited for clarity. ). My question is, are the volatiles needed as shown? Or does the ManualResetEvent.Set have an implicit memory barrier as I've read Thread.Start does? Or would an explicit MemoryBarrier call be better than the volatiles? Or is it completely wrong? Also, the fact that the "implicit memory barrier behavior" in some operations is not documented as far as I

How do I write to a memory-mapped address in Rust?

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to make "Blinky" for STM32F1xx in Rust. I know that there are libs for it, but I want to make my own "lib" for learning purposes. I can access STM32's "registers" by their addresses like this in C: *(uint32_t*)(0x40021000 + 0x018) |= 0x10; *(uint32_t*)(0x40011000 + 0x004) |= 0x33; *(uint32_t*)(0x40011000 + 0x004) &= ~0xCC; *(uint32_t*)(0x40011000 + 0x10) |= 0x300; while(1) {} This writes some bits to the RCC_APB2ENR register to enable clocking of port C, configures pins and enables LEDs on my Discovery. I need to re-write this it

How do I write to a memory-mapped address in Rust?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to make "Blinky" for STM32F1xx in Rust. I know that there are libs for it, but I want to make my own "lib" for learning purposes. I can access STM32's "registers" by their addresses like this in C: *(uint32_t*)(0x40021000 + 0x018) |= 0x10; *(uint32_t*)(0x40011000 + 0x004) |= 0x33; *(uint32_t*)(0x40011000 + 0x004) &= ~0xCC; *(uint32_t*)(0x40011000 + 0x10) |= 0x300; while(1) {} This writes some bits to the RCC_APB2ENR register to enable clocking of port C, configures pins and enables LEDs on my Discovery. I need to re-write this it

AtomicInteger lazySet vs. set

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the difference between the lazySet and set methods of AtomicInteger ? The documentation doesn't have much to say about lazySet : Eventually sets to the given value. It seems that the stored value will not be immediately set to the desired value but will instead be scheduled to be set some time in the future. But, what is the practical use of this method? Any example? 回答1: Cited straight from Bug 6275329 : As probably the last little JSR166 follow-up for Mustang, we added a "lazySet" method to the Atomic classes (AtomicInteger,

Linux assembler error “impossible constraint in ‘asm’”

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm starting with assembler under Linux. I have saved the following code as testasm.c and compiled it with: gcc testasm.c -otestasm The compiler replies: "impossible constraint in ‘asm’". #include <stdio.h> int main(void) { int foo=10,bar=15; __asm__ __volatile__ ("addl %%ebx,%%eax" : "=eax"(foo) : "eax"(foo), "ebx"(bar) : "eax" ); printf("foo = %d", foo); return 0; } How can I resolve this problem? (I've copied the example from here .) Debian Lenny, kernel 2.6.26-2-amd64 gcc version 4.3.2 (Debian 4.3.2-1.1) Resolution : See the accepted