race-condition

Segmentation Fault p_thread with a possible race condition

北慕城南 提交于 2019-12-01 12:33:13
问题 Issue: I created a linked list of Child thread TIDS and want to wait on all the child tids to finish execution before I continue my main thread. Basically I have directory traversal (a directory is specified by the members of a given struct ). Every time I see a directory or file I create a new thread and put its threadID into the linked list. However when I traverse the linked list and call pthread_join I get a segmentation fault (core dumped) - I cannot understand why. I believe in may have

jquery ajax call not asynchronous

泄露秘密 提交于 2019-12-01 08:20:35
I am fresh to jQuery's implementation of it's AJAX methods. I have a simple setup that accesses two different pages, one which takes 10 seconds to complete (I have a timer set on it) and one which checks on the status of the first page. The two functions are progressCheck() which requests its page every second with the latest status and beginLogin() which takes 10 seconds to load. I set a value in the user object on the server that both pages access through symfony 1.4. The issue is that the progressCheck() works correctly until I click beginLogin() , then no changes are made until beginLogin(

OpenCL float sum reduction

最后都变了- 提交于 2019-12-01 06:43:48
I would like to apply a reduce on this piece of my kernel code (1 dimensional data): __local float sum = 0; int i; for(i = 0; i < length; i++) sum += //some operation depending on i here; Instead of having just 1 thread that performs this operation, I would like to have n threads (with n = length) and at the end having 1 thread to make the total sum. In pseudo code, I would like to able to write something like this: int i = get_global_id(0); __local float sum = 0; sum += //some operation depending on i here; barrier(CLK_LOCAL_MEM_FENCE); if(i == 0) res = sum; Is there a way? I have a race

Generating a race condition with MRI

心不动则不痛 提交于 2019-12-01 05:10:30
I was wondering whether it's easy to make a race condition using MRI ruby(2.0.0) and some global variables, but as it turns out it's not that easy. It looks like it should fail at some point, but it doesn't and I've been running it for 10 minutes. This is the code I've been trying to achieve it: def inc(*) a = $x a += 1 a *= 3000 a /= 3000 $x = a end THREADS = 10 COUNT = 5000 loop do $x = 1 THREADS.times.map do Thread.new { COUNT.times(&method(:inc)) } end.each(&:join) break puts "woo hoo!" if $x != THREADS * COUNT + 1 end puts $x Why am I not able to generate (or detect) the expected race

Concurrently reading a Map while a single background thread regularly modifies it

ε祈祈猫儿з 提交于 2019-12-01 03:52:41
I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside updateLiveSockets() method and then I have a method getNextSocket() which will be called by multiple reader threads to get a live socket available which uses the same map to get this information. public class SocketManager { private static final Random random = new Random(); private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private final AtomicReference<Map<Datacenters, List<SocketHolder>>> liveSocketsByDatacenter = new

How to properly avoid Mysql Race Conditions

心已入冬 提交于 2019-11-30 21:32:18
I know this has been asked before, but I'm still confused and would like to avoid any problems before I go into programming if possible. I plan on having an internal website with at least 100 users active at any given time. Users would post an item (inserted into db with a 0 as its value) and that item would be shown via a php site (db query). Users then get the option to press a button and lock that item as theirs (assign the value of that item as their id) How do I ensure that 2 or more users don't retrieve the same item at the same time. I know in programming like c++ I would just use plain

Meteor: Could a race condition happen with Meteor.collections on server side?

早过忘川 提交于 2019-11-30 20:11:59
in my server/server.js Meteor.methods({ saveOnServer: function() { var totalCount = Collections.find({ "some": "condition" }).count(); if (totalCount) { var customerId = Collections.update('someId', { "$addToSet": { objects: object } }, function(err) { if (err) { throw err; } else { return true; } }); } else {} } }); I'm afraid that when saveOnServer() is called by 2 clients at the same time, it will return the same totalCount for each client and basically end up inserting same integer number into object id. The end goal is to insert row on the server side with an atomic operation that only

Is it possible to store pointers in shared memory without using offsets?

南楼画角 提交于 2019-11-30 19:17:58
When using shared memory, each process may mmap the shared region into a different area of its respective address space. This means that when storing pointers within the shared region, you need to store them as offsets of the start of the shared region. Unfortunately, this complicates use of atomic instructions (e.g. if you're trying to write a lock free algorithm ). For example, say you have a bunch of reference counted nodes in shared memory, created by a single writer. The writer periodically atomically updates a pointer 'p' to point to a valid node with positive reference count. Readers

MySQL Race Conditions

血红的双手。 提交于 2019-11-30 19:10:08
问题 Does this cause a race condition with MySQL (InnoDB): Start Transaction. Try to get record. If record doesn't exist, return. If record exists, delete it and add a log entry saying that is was deleted. End Transaction (commit/rollback). Is it possible for another process to start just before the delete step in 2b, detect the presence of the record and then have both processes enter item delete entries into the log? Are there any precautions that I need to take? Thanks. 回答1: Use 'select for

Race Condition in Async/Await Code

不打扰是莪最后的温柔 提交于 2019-11-30 18:49:34
I just wonder whether a race condition occurs in the code below: int readingFiles; async Task<string> ReadFile (string file) { ++readingFiles; var text = await Stream.ReadFileAsync(file); --readingFiles; return text; } If ReadFile method is executed by a thread pool thread, readingFiles will be accessed by two different threads and the readingFiles variable is not protected by any synchronization idioms. It means that the first update to readingFiles should not be visible to the other thread executing "--readingFiles". However, I've NEVER seen that readingFiles equals -1 after "--readingFiles"