[I now see that my question is a  I will vote to close it.]  Can one reliably test lock-free code in C++? Is there a known technique?  Can one compose a proper unit test? In lock-free-programming, are proper unit tests even possible?  I see no obvious way to force wrong lock-free code to fail reliably. Apparently, I am missing a concept.  (See also )  EXAMPLE  Concurrency wants long examples, unfortunately. I have made the below example as short as I can. The example is correct as far as I know, but suppose that you broke it&mdash;say, by changing memory_order_release to memory_order_relaxed. Even when broken, the example still, spuriously succeeds on my machine. With memory_order_relaxed, the example should fail; but, for purpose of testing, I do not know how to make it fail.  Do you?  Unit testing seems doubtful when one is unable to compose a test to flunk bad code.  #include &lt;atomic&gt; #include &lt;thread&gt; #include &lt;cstdlib&gt; #include &lt;iostream&gt;  const int threshold     =  0x100; const int large_integer = 0x1000;  // Gradually increase the integer to which q points until it reaches the // threshold.  Then, release. void inflate(std::atomic_bool *const p_atom, int *const q) {     while (*q &lt; threshold) ++*q;     p_atom-&gt;store(true, std::memory_order_release); }  int main() {     std::atomic_bool atom{false};     int n{0};      // Dispatch the inflator, letting it begin gradually, in the background, to     // inflate the integer n.     std::thread inflator(inflate, &amp;atom, &amp;n);      // Waste some time....     for (int i = large_integer; i; --i) {}      // Spin until the inflator has released.     {         int no_of_tries = 0;         while (!atom.load(std::memory_order_acquire)) ++no_of_tries;         std::cout &lt;&lt; "tried " &lt;&lt; no_of_tries &lt;&lt; " times" &lt;&lt; std::endl;     }      // Verify that the integer n has reached the threshold.     if (n == threshold) {         std::cout &lt;&lt; "succeeded" &lt;&lt; std::endl;     }     else {         std::cout &lt;&lt; "failed" &lt;&lt; std::endl;         std::cerr &lt;&lt; "error"  &lt;&lt; std::endl;         std::exit(1);     }      inflator.join();     return 0; }
I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield.  I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people have gone about testing those kinds of issues that only show up when two threads interact in a given manner?  This seems like a really key problem for programmers today, it would be useful to pool our knowledge on this one imho.
Mail on Big Sur does not reliably find dollar values Get the image URL I want to render an image as a background image via an inline style in twig. I created a field called bg_image and attached it to the standard plain page.  After fiddling around for hours I was able to get the Image URL in node.html.twig  {{ file_url(node.field_bg_image.0.entity.uri.value) }}   but I could not get it to work inside field--field-bg_image.html.twig  Can I get the node from there anyhow, so I can then get the image?  How can I get the image URL to use as inline style? I thought maybe I can pass a variable from field--field-bg_image.html.twig to image.html.twig and then just render  {{ uri }}   instead of  &lt;img{{ attributes.addClass(classes) }} /&gt;   but I could not get it to pass the variable there unless I use includes  {% include 'image.html.twig' with {'image': image, 'isFromField': isFromField} %}   (isFromField is true, when it comes from the field--field-bg_image.html.twig) But that didn't work either. The Image was never rendered that way.  Would be very glad if you can help - my php knowledge is very basic. Thanks What is the difference between call and apply? Does the following limit exist? $$\lim_{x \to 0} x\sin\left(\frac{1}{x}\right)$$  If yes, then I have to find it; if no, then I need to give reason why. I couldn’t figure out how to prove this formally, can someone please help me out. How do I troubleshoot high 'svchost.exe' usage in Windows 7? Showing that $\int_0^\infty x^{-x} \mathrm{d}x \leq 2$. Why does the series $\sum_{n=1}^\infty\frac1n$ not converge? Can someone give a simple explanation as to why the       $$\sum_{n=1}^\infty\frac1n=\frac 1 1 + \frac 12 + \frac 13 + \cdots $$   doesn't converge, on the other hand it grows very slowly?   I'd prefer an easily comprehensible explanation rather than a rigorous proof regularly found in undergraduate textbooks. Why draw blood from veins rather than arteries? Why draw blood from veins rather than arteries? Is it more convenient or safer? How to get the Input and output in a terminal to a text file? I want to create a text file which will add each command I am going to run on the terminal as a new line entry in the text file. i.e., I need to keep a record of what are the things I'm doing in the terminal. Further if I can keep a record of outputs I'm getting in the terminal, along with the inputs in the terminal, as a text file, it will be much better.   Each time I forget a command I have to search again in the Internet for the command.  Can I can make a file like above? Smallest positive element of $ \{ax + by: x,y \in \mathbb{Z}\}$ is $\gcd(a,b)$ Let $S = \{ax + by: x,y \in \mathbb{Z}\}$  and let $e &gt; 0$ be the smallest element in $S$. Prove that $e \mid a$, and hence prove that $e = \gcd(a,b)$  I'm afraid I can't provide much of my initial working here because I'm at a loss of how to start.  I suppose that to show $e\mid a$ I would have to show that $eg = a$ for some $g \in \mathbb{Z}$. But I have no idea how I would do this. 20GB of Temporary Files, Only 50MB in Temp Folder I recently discovered that the Settings app is showing around 20GB of space used by temporary files. But when I go to remove them I can only remove about 28MB. When I open the temp folder by using Run and then %temp% it only shows around 40-50MB of files right after boot. How can I remove these 20GB of invisible files? I only have a 240GB SSD so space is quite scarce. Here are a few photos:    I run Windows 10 Home Activated. I have tried Disk Cleanup but this removed only around 30MB of files.  UPDATE: After turning on hidden items I found a folder name WINDOWS-BT, after doing some research it turned out to be a folder for the previous windows version. I deleted it using TakeOwnerShip pro and this removed around 12GB of temporary files, but 8GB still remain. I am currently downloading TreeSize free to find out where the other 8GB is.  UPDATE 2: Hi, I downloaded TreeSizeFree and I didn't really find anything there.   The biggest folder is 87GB of Program Files which mainly consists of my GTA V install. The Program Files (x86) folder was mainly made up of my Steam games (CS:GO, Besiege, etc). The 5.5GB [3 Files] location was noted as being my pagefile.    The Windows folder shows up as 25GB when in Settings it is only 18GB, this could explain where the other 8GB are coming from. What are some things I should look for in there?  FINAL UPDATE: After deleting the Windows-BT folder it reappeared a few hours later. I decided to check from system updates and surely enough one was downloaded and pending to be installed. After installing the update the Windows-BT folder disappeared on it's own and a new folder taking up 20GB called Windows.old was created. I then followed this  to remove the .old folder and I had all my disk space back! NOTE: Disk Cleanup wasn't able to find the Windows.old folder, this is why I had to delete it from the settings app. I have 3 folders with large amount of data in each which has to be maintained seperately. Can I create a sym link or shortcut.in windows which should show me the merged contents of the 3 folders. I am not looking for library conf in Win7.   Any suggestion is highly appreciated. I am trying to show that $X^n-Y^m$ is irreducible in $\Bbb{C}[X,Y]$ iff $\gcd(n,m)=1$ where $n,m$ are positive integers.    I showed that if $\gcd(n,m)$ is not $1$, then $X^n-Y^m$ is reducible. How to show the other direction. Please help. R : Format the text file output Changing background color to transparent in GeoServer? How to set the background color to transparent. I want use style which describe in *.sld file for all my photo with tif format. How to do that? iPhone asks 'Trust This Computer' again (I am on macOS 10.14.6 and iOS 12.4)   I am certain that I have trusted my Mac before. Without the latter trust, I can also access the phone in iTunes.   I have tried reset "Location and Privacy" on my phone. Then   When connecting the iPhone with iTunes running, it asks for the trust and I trust it.  Reboot my Mac and the phone asks for another trust.   Is there some known malware mimics system behavior and steal data from an iPhone?  (I do have installed some pir*ted software recently. That's my fault.) Getting coordinates by clicking on QGIS Canvas with PyQGIS? What are good basic statistics to use for ordinal data? I have some  gained from survey questions.  In my case they are  responses (Strongly Disagree-Disagree-Neutral-Agree-Strongly Agree).  In my data they are coded as 1-5.  I  don't think means would mean much here, so what basic summary statistics are considered usefull? Mouse pointer and keyboard Freeze when pluggin in external hard drive so as I say in the title I have this very big, annoying problem. On my new PC (HP Omen 2020, i7-10750h, Nvidia RTX 2070, 16GB RAM) when I connect an external hard drive (precisely an WD My Passport Ultra, 3TB) I get occasionally mouse and keyboard freezes. Practically, the system becomes unusable. The mouse and keyboards works, they even show in device manager, but from time to time (too often) they &quot;freezes&quot;: mouse pointer freeze, and it won't respond to my input, and keyboard too, if I type something it will not respond. First I thought this was a behaviour due to bad drivers, or something related to my new PC, the fact that it has USB 3.1 ports. But then I've noticed that this fact happens only when I connect my WD Hard Disk (which is USB 3.0) to my pc. I've tried some stuff online, suggesting to update drivers, change some windows settings, but with no success. My guess is that the hard disk and the mouse-keyboard does interfere with each other in some ways. I guess that it's a software problem, at driver levels maybe, not a physical one. When the mouse doesn't respond, I've tried to use the touchpad on the notebook, and it does work. So it's not a windows freeze, it's just the device (mouse-keyboard-receiver) that doesn't respond. The mouse and keyboard are from Logitech, bot connected with the Unifiying receiver (a wireless receiver they provide for the mouse and the keyboard). Model: MX Anywhere 2S for the mouse, K360 for the keyboard. Please, help me solve this problem, monday I start taking my engineering class lessons from MS Teams, and I need my pc up and running and well responsive (I need to access data from the hard disk while I take classes). PS: I've seen that there are some other questions like this in the forum, but none of them seems to provide a solution to the problem. I would also change the external hard drive in the future, but I need to know that the problem with this one won't show with another hard drive, or other devices. I've already sent this very same post to Microsoft community, I really need help with this thing otherwise it will be a problem following my online classes. Thank you if you will try to help me EDIT: On the notebook in question I have 4 USB 3.1 Ports, with two ports on each side, and a single Type-C Thunderbolt port (I'm not counting that one cause both the hard disk and the logitech receiver are USB 3.0 type A connectors). I've already tried switching USB port, connecting the WD Hard Disk to another port, doing the same on the logitech receiver, and I've even tried putting them one on the left side and the other to the right side, to minimize &quot;interference&quot; as someone suggested. But nothing, I still got this problem, which seems driver-related. Hope this will give more info Quantum mechanics textbooks that use path integrals I'm looking for a textbook in quantum mechanics that relies heavily on Green functions and the path integral formalism to supplement my QM books. I want to do some calculations using alternative methods (path integrals, green functions, Lagrangians etc).