synchronization

Why is “sleeping” not allowed while holding a spinlock? [duplicate]

廉价感情. 提交于 2019-12-03 09:57:16
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Why can't you sleep while holding spinlock? As far as I know, spinlocks should be used in short duration, and are only choices in code such as interrupt handler where sleeping (preemption) is not allowed. However, I do not know why there is such a "rule" that there SHOULD BE no sleeping at all while holding a spinlock. I know that it is not a recommended practice (since it is detrimental in performance), but I

Mutli Player Game synchronization

房东的猫 提交于 2019-12-03 09:55:49
问题 The Situation: I would like to ask what's the best logic for synchronizing objects in a multiplayer 1:1 game using BT or a web server. The game has two players, each of them has multiple guns & bullets, the bullets are created dynamically and disappear after a while, the players my move objects around simultaneously. The Problem: I have a real issue with synchronization, since the bullets on one device may be faster than other, also they may have already gone or hit an object on one device

Simplifying VCL thread wrapper code

隐身守侯 提交于 2019-12-03 09:45:09
I am using thread wrapper which checks if function which updates VCL (which also has some arguments) was called from main thread or not and then executes in within the context of Main thread always. It works but I want to make it simpler. The problem is that I have to repeat this code in every function which needs VCL synchronization which is prone to errors. Is there a way to make this wrapper simpler and more re-useable? Note that this particular wrapper only uses one parameter but there can be any number of parameters which are copied to TLocalArgs and passed on. Current code: boost::scoped

Alternative to spinlock

烈酒焚心 提交于 2019-12-03 09:10:39
I am using the following spinlock approach: while(!hasPerformedAction()){ //wait for the user to perform the action //can add timer here too } setHasPerformedAction(false); return getActionPerfomed(); this basically waits for a user to perform an action and then returns it. Currently something requests an answer from the user before continuing, this is why I wait until input is received. However I was wondering if this is inefficient and if we are waiting for a while (i.e. <= 30 secs) will it slow down the pc that is running this app. Are there any other alternatives using this approach i.e.

CUDA: synchronizing threads

大城市里の小女人 提交于 2019-12-03 09:08:36
问题 Almost anywhere I read about programming with CUDA there is a mention of the importance that all of the threads in a warp do the same thing. In my code I have a situation where I can't avoid a certain condition. It looks like this: // some math code, calculating d1, d2 if (d1 < 0.5) { buffer[x1] += 1; // buffer is in the global memory } if (d2 < 0.5) { buffer[x2] += 1; } // some more math code. Some of the threads might enter into one for the conditions, some might enter into both and other

Implied synchronization with MPI_BCAST for both sender and receivers?

 ̄綄美尐妖づ 提交于 2019-12-03 08:49:18
When calling MPI_BCAST, is there any implied synchronization? For example, if the sender process were to get to the MPI_BCAST before others could it do the BCAST and then continue without any acknowledgements? Some recent tests with code like: program test include 'mpif.h' integer ierr, tid, tmp call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, tid, ierr) tmp = tid if(tid.eq.0) then call MPI_BCAST(tmp,1,MPI_INTEGER,MPI_ROOT,MPI_COMM_WORLD, ierr) else endif write(*,*) tid,'done' call MPI_FINALIZE(ierr) end shows that with two threads they both reach completion, despite only the sender

Syncing a local sqlite file to iCloud

江枫思渺然 提交于 2019-12-03 08:44:30
问题 I store some data in my iOS app directly in a local .sqlite file. I chose to do this instead of CoreData because the data will need to be compatible with non-Apple platforms. Now, I'm trying to come up with the best way to sync this file over iCloud. I know you can't sync it directly, for many reasons. I know CoreData is able to sync its DBs, but even ignoring that using CD would essentially lock this file into Apple platforms (I think? I've only looked into CD a bit), I need the iCloud

Questions concerning iCloud + core data

ぃ、小莉子 提交于 2019-12-03 08:43:11
I have an app on the app store, that uses coredata as storage. I wan't to update the app with iCloud synchronization as new feature. Following apple`s sample code, I managed to have my core data storage synchronize between devices. However, I'm experiencing problems when either iCloud synchronization is turned off/on in the app on only one of the devices, or when the app is deleted from the device and the reinstalled. In both cases, data is not synchronized back to the device, although it is available just fine on a second device (which was not disabled/reinstalled). I also found that all

Data sync between database and google calendar

廉价感情. 提交于 2019-12-03 08:28:05
I would like to sync my db (tasks on my db, that have a decription, a date, a start time and an end time, and a user) with Google calendar. For sync with google i plan to use these components (of course I could somehow write the whole stuff on my own but this is something I can plan for the future now I am short of time, or in alternative can you suggest some working code that connects to google calendar to send/recieve data?). Now my main problem is not really linked to Delphi programming anyway I must ask a Delphi related questions because other questions get unviewd (like this one i asked).

Synchronize two databases schema in MySQL

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:09:12
问题 I was looking for a portable script or command line program that can synchronize two MySQL databases schema. I am not looking for a GUI based solution because that can't be automated or run with the buid/deployment tool. Basically what it should do is scan database1 and database2. Check the schema difference (tables and indexes) and propose a bunch of SQL statements to run on one so that it gets the similiar structure of the other minimizing data damage as much as possible. If someone can