wait and notify in C/C++ shared memory

Instead of the Java object that you would use to wait/notify, you need two objects: a mutex and a condition variable. These are initialized with pthread_mutex_init and pthread_cond_init. Where you would have synchronized on the Java object, use pthread_mutex_lock and pthread_mutex_unlock (note that in C you have to pair these yourself manually). If you don’t … Read more

Why is there no generic synchronized queue in .NET?

Update – in .NET 4, there now is ConcurrentQueue<T> in System.Collections.Concurrent, as documented here http://msdn.microsoft.com/en-us/library/dd267265.aspx. It’s interesting to note that its IsSynchronized method (rightly) returns false. ConcurrentQueue<T> is a complete ground up rewrite, creating copies of the queue to enumerate, and using advanced no-lock techniques like Interlocked.CompareExchange() and Thread.SpinWait(). The rest of this answer is … Read more

Sharing a variable between multiple different threads

Both T1 and T2 can refer to a class containing this variable. You can then make this variable volatile, and this means that Changes to that variable are immediately visible in both threads. See this article for more info. Volatile variables share the visibility features of synchronized but none of the atomicity features. This means … Read more

Multiplayer Game Synchronization

The basic approach to this is something called Dead Reckoning and a quite nice article about it can be found here. Basically it is a predication algorithm for where entities positions will be guessed at for the times between server updates. There are more advanced methodologies that build on this concept, but it is a … Read more

Command-line/API for Schema Compare in SSDT SQL Server Database Project?

SOURCE Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=AspBaselineDB; /tf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac TARGET Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=%AspTargetDB-2%; /tf:%DriveSpec%\%DacPath%\%AspTargetDB%.dacpac COMPARE & GENERATE the Delta script sqlpackage.exe /a:Script /sf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac /tf:%DriveSpec%\%DacPath%\AspNetDb\%AspTargetDB%.dacpac /tdn:aspTargetdb /op:%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql EXECUTE the script sqlcmd.exe -S %Server%\aspnetdbAmexDev -i %DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql I do this in CMD scripting as our IT dept will not allow unsigned PowerShell scripts and they won’t purchase a cert. This … Read more

Correct way to synchronize ArrayList in java

You’re synchronizing twice, which is pointless and possibly slows down the code: changes while iterating over the list need a synchronnization over the entire operation, which you are doing with synchronized (in_queue_list) Using Collections.synchronizedList() is superfluous in that case (it creates a wrapper that synchronizes individual operations). However, since you are emptying the list completely, … Read more

Is there a solution to automatically synchronize Emacs org-mode with one of the web based todo services?

I have been using Org-mode with Remember the Milk quite nicely. here is my setup: (require org-feed) (setq org-feed-alist ‘((“Remember The Milk” “https://www.rememberthemilk.com/rss/jonnay/” “~/org/GTD.org” “Remember The Milk” :template “* TODO %title\n %a\n ” ))) ;;* rtm feed timer (run-at-time 3600 3600 ‘org-feed-update-all) The only problem is that I get asked for authentication the first time … Read more

How to share semaphores between processes using shared memory

It’s easy to share named POSIX semaphores Choose a name for your semaphore #define SNAME “/mysem” Use sem_open with O_CREAT in the process that creates them sem_t *sem = sem_open(SNAME, O_CREAT, 0644, 3); /* Initial value is 3. */ Open semaphores in the other processes sem_t *sem = sem_open(SEM_NAME, 0); /* Open a preexisting semaphore. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)