locking

run command/script when lock/unlock windows station?

若如初见. 提交于 2019-12-02 22:23:40
I have Windows 7 pro at work. My problem is I keep on forgetting to clock in/clock out (using the intranet timesheet system). Is there a way to run a script or command to automatically open the timesheet page each time I lock/unlock my station? Yes, windows 7 task scheduler allows a dizzying array of new ways to schedule tasks: One is on log on, and another is on event which could be a security event for locking the workstation. Administrative Tools --> Task Scheduler - Create Task --> Triggers Tab --> New Button --> Begin Task drop down box... etc. 来源: https://stackoverflow.com/questions

ת How to Find Out Who Is Locking a Table in MySQL

匿名 (未验证) 提交于 2019-12-02 22:06:11
MySQL is adding more tools to monitor its internals with every new release, but one thing it still lacks is a way to find out who is locking what, and therefore which transactions block which other ones. This is such a vital feature that I’m considering writing my own patch to the source! Still, it is possible, to a limited extent, to find out who’s locking resources. In this article I’ll explain how you can do that. innotop Introduction Here’s the situation: you are trying to update a table and every time you issue the query, it hangs until it times out and tells you the lock wait timeout was

SQL Server Latches and their indication of performance issues

别等时光非礼了梦想. 提交于 2019-12-02 20:40:35
I am trying to understand a potential performance issue with our database (SQL 2008) and in particular one performance counter, SQLServer:Latches\Total Latch Wait Time Total Latch Wait Time (ms). We are seeing a slow down in DB response times and the only correlating spike that I can match it with is a spike in Total Latch Wait Time and Latch Waits/sec. I am not seeing any particular bottleneck in disk IO, CPU usage or memory. The common explanation of a SQLServer latch is that it is a lightweight lock, but I am trying to get a more detailed understanding of what a latch is, how it differs

Does the C# Yield free a lock?

此生再无相见时 提交于 2019-12-02 20:07:11
I have the following method: public static IEnumerable<Dictionary<string, object>> GetRowsIter (this SqlCeResultSet resultSet) { // Make sure we don't multi thread the database. lock (Database) { if (resultSet.HasRows) { resultSet.Read(); do { var resultList = new Dictionary<string, object>(); for (int i = 0; i < resultSet.FieldCount; i++) { var value = resultSet.GetValue(i); resultList.Add(resultSet.GetName(i), value == DBNull.Value ? null : value); } yield return resultList; } while (resultSet.Read()); } yield break; } I just added the lock(Database) to try and get rid of some concurancy

How can I create a non-file lock in PHP?

折月煮酒 提交于 2019-12-02 20:00:48
问题 I have a maintenance script in PHP that updates and repairs the database. In theory, running two scripts simultaneously shouldn't be a problem, but I want to be extra safe by putting a lock in a variable in PHP. The problem, of course, is that I can't store it in a $_SESSION variable because sessions only apply to one user. Is there any way I can store this lock in a variable? I'd prefer to not create and delete a file in case the server dies in the middle of the script. 回答1: MySQL has GET

Prevent two threads entering a code block with the same value

那年仲夏 提交于 2019-12-02 19:36:12
Say I have this function (assume I'm accessing Cache in a threadsafe way): object GetCachedValue(string id) { if (!Cache.ContainsKey(id)) { //long running operation to fetch the value for id object value = GetTheValueForId(id); Cache.Add(id, value); } return Cache[id]; } I want to prevent two threads from running the " long running operation " at the same time for the same value . Obviously I can wrap the whole thing in a lock(), but then the whole function would block regardless of value and I want two threads to be able to perform the long running operation as long as they're looking for

How are mutex and lock structures implemented?

谁说胖子不能爱 提交于 2019-12-02 19:12:31
I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions for the CPUs MMU? James Black You may want to look at these links, but the main one is the Test-and-set on Wikipedia: http://en.wikipedia.org/wiki/Test-and-set How are mutexes implemented? You can also look at this patent: http://www.faqs.org/patents/app/20080222331 Most mutual exclusion and synchronization mechanisms use hardware atomic operations, as others have pointed out. However, it is

Is spin lock useful in a single processor uni core architecture?

你说的曾经没有我的故事 提交于 2019-12-02 18:26:13
I am confused by the function of spin lock. The spin lock is used to stop the process from re-scheduling. However, in a machine with just one core, is it useful to use spin lock to prevent context switching? brianegge Short answer: no. According to http://uw714doc.sco.com/en/man/html.3synch/Intro.3synch.html Spin locks must not be used on a single processor system. In the best case, a spin lock on a single processor system will waste resources, slowing down the owner of the lock; in the worst case, it will deadlock the processor. From: http://blogs.microsoft.co.il/blogs/sasha/archive/2008/08

How are the Spring @Transactional and the Hibernate @LockMode annotations related

谁说我不能喝 提交于 2019-12-02 18:23:25
I wish to know the relation between transactions and locks. To be more specific, how is Spring's @Transactional related to Hibernate's LockMode. https://docs.jboss.org/hibernate/orm/4.0/devguide/en-US/html/ch05.html . http://docs.spring.io/autorepo/docs/spring/4.2.x/spring-framework-reference/html/transaction.html If I dont specify any lock while creating Session Object, and use @Transactional with readOnly as false , am I using Pessimistic Concurrenct Control. It would be a great help, if anyone can tell me the relation between (Optimistic/Pessimistic) Concurrency Control and Transactions.

Asynchronous locking based on a key

青春壹個敷衍的年華 提交于 2019-12-02 18:22:54
I'm attempting to figure out an issue that has been raised with my ImageProcessor library here where I am getting intermittent file access errors when adding items to the cache. System.IO.IOException: The process cannot access the file 'D:\home\site\wwwroot\app_data\cache\0\6\5\f\2\7\065f27fc2c8e843443d210a1e84d1ea28bbab6c4.webp' because it is being used by another process. I wrote a class designed to perform an asynchronous lock based upon a key generated by a hashed url but it seems I have missed something in the implementation. My locking class public sealed class AsyncDuplicateLock { ///