synchronization

Global variables and threads

眉间皱痕 提交于 2019-12-23 04:55:07
问题 If I have a global counter and I have two threads that are each incrementing it 100 times in a loop, why is it possible that I can have a value other than 200? I don't see how accessing the variable is nonatomic. 回答1: That is because for most environments, incrementing a memory location is not an atomic operation. The sequence of events would be something like The compiler places the value 0 at the memory address 0xABCD Thread 1 reads 0xABCD into a register and increments the register value

Network Time Synchronization with Java

本小妞迷上赌 提交于 2019-12-23 04:51:08
问题 I'm creating a p2p audio-midi streaming application using Java (unfortunately) and I'm searching for a way to provide network time synchronization between certain peers (sources) using a reliable protocol implementation (like NTP) but I can't find any related libraries to use.I also have a limited amount of time to spend in order to implement something like this myself. So, does anyone know any solutions for network time synchronization using Java, NTP or alternative protocols/methods/ideas ?

Automated Synchronisation of server files and local files

血红的双手。 提交于 2019-12-23 04:47:10
问题 Is there any application that does a automated update of the server file and local file? WinSCP does the local to server update and uni directional. Is there any bidirectional application? 回答1: Winscp is bi direcional. I currently use this program to automate a directory of documents to 100+ computers. A simple batch file containing the commands found on this page: http://winscp.net/eng/docs/scriptcommand_synchronize Below,is the batch file I use to accomplish a sync from an ftp server to a

triggering an event simultaneously on multiple iOS devices

放肆的年华 提交于 2019-12-23 04:27:20
问题 I would like to trigger an event (e.g. play music) on multiple iOS devices at the exact same time (by means of milliseconds) My approach is to keep a socket connection and send a timestamp to iOS devices (10 seconds later from current time) and trigger the event on iOS devices at that timestamp. Problem is iOS devices might differ 1 or 2 seconds and that would cause a desynchronize. And even timestamps are pointing out the same time on each devices (AFAIK) they are not on millisecond

strict N process synchronization using 2 semaphores

老子叫甜甜 提交于 2019-12-23 03:58:07
问题 a few years ago I had an Operating Systems seminar. I had been tasked to create an algorithm for process synchronization using as few semaphores as possible. It should have looked like this: P1 -> P2 -> P3 -> P4 -> P5 P(n) - process Only one process running at a time and strict ordering was needed . Last year I came with solution using 3 semaphores (effectively creating a barrier). Here is my algorithm: P S1 S1 S1 S1 4W1 W0 W0 W0 W0 4S0 P S2 S2 S2 3W2 W1 W1 W1 3S1 P S1 S1 2W1 W0 W0 2S0 P S2

Algorithm for expressing reordering, as minimum number of object moves

家住魔仙堡 提交于 2019-12-23 03:41:54
问题 This problem arises in synchronization of arrays (ordered sets) of objects. Specifically, consider an array of items, synchronized to another computer. The user moves one or more objects, thus reordering the array, behind my back. When my program wakes up, I see the new order, and I know the old order. I must transmit the changes to the other computer, reproducing the new order there. Here's an example: index 0 1 2 old order A B C new order C A B Define a move as moving a given object to a

Algorithm for expressing reordering, as minimum number of object moves

家住魔仙堡 提交于 2019-12-23 03:41:11
问题 This problem arises in synchronization of arrays (ordered sets) of objects. Specifically, consider an array of items, synchronized to another computer. The user moves one or more objects, thus reordering the array, behind my back. When my program wakes up, I see the new order, and I know the old order. I must transmit the changes to the other computer, reproducing the new order there. Here's an example: index 0 1 2 old order A B C new order C A B Define a move as moving a given object to a

How is class level locking achieved in java?

六月ゝ 毕业季﹏ 提交于 2019-12-23 03:38:19
问题 I am aware of locking concepts with synchronization of static and non static methods to lock classes and instances respectively. What I am not able to understand is, how is class level lock achieved? I mean, class is a template only, with no physical significance. So, when we say that class level locking is achieved with synchronizing static methods what happens then? Do all the objects of that class get locked or some other process? With what I could find out with my search is that there are

How can one synchronize an external application with a DigitalMicrograph script?

守給你的承諾、 提交于 2019-12-23 01:43:27
问题 This question has been inspired by the question 'Call script from command line'. How can one write a script which acts on 'trigger events' in an application other than DigitalMicrograph? i.e. some script functionality should be triggered by an external application. 回答1: The scripting language does not offer many 'external' interfaces in its current state. It is possible to call out to an external process with the command LaunchExternalProcess and wait for the process to complete, but there is

Android: Synchronize Timestamps of Sensors and GPS

喜夏-厌秋 提交于 2019-12-23 01:16:37
问题 Is there a way to synchronize the timestamps in values meassured by Sensors (e.g. acceleration) ( SensorEvent.timestamp ) and GPS ( Location.getTime() ). SensorEvent.timestamp are the nanoseconds since the device has been booted (local time). Location.getTime() are the miliseconds since1970 (global time). One solution I had in mind was to calculate the offset between the local time and the global (GPS) time. But the problem is, that the time in Location is the time when the GPS-message