0

I'm trying to understand whether a process would interfere another process running on the same piece of hardware system. This could happen in a wild range of products. ie. vmware or as simple as running multiple .net applications.

If I have repetitive lock happening of a particular process say, interlock, or lock keywords in C# terms, will it affect the performance other processes due to its intensive usage of lock? The setting is a heavy loaded www system, and I am experience some situational delay, I would like to determine whether the delay was caused by a dense while loop of locks that was completely isolated by a different windows kernel thread.

If there is no isolation, will application domain in .net help me in this case?

Thanks for your answer

Bamboo
  • 2,046
  • 2
  • 16
  • 21
  • 2
    A lock is local to a process. There are some locking mechanisms that can be used for interprocess synchronisation, like the `Mutex` and `Semaphore` classes. – Elian Ebbing Feb 21 '12 at 06:41

3 Answers3

3

No it won't. A lock in C#, and .Net overall, is local to a process. It can't directly affect other processes on the machine.

A lock statement operates on a particular instance of an object. In order for a lock to effect multiple processes they would all have to lock on the same instance of an object. This is not possible since objects are local to a process.

Elian Ebbing
  • 18,779
  • 5
  • 48
  • 56
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
1

I'm trying to understand whether a process would interfere another process running on the same piece of hardware system

Is there anything that lead you to this question or are you simply just imagining some scenario based on a whim?

A lock is local to the process running those threads. If you want to synchronize across processes, consider using a Semaphore.

will it affect the performance other processes due to its intensive usage of lock?

Short answer, no. Of course, unfettered and whimsical use of lock will probably lead to some live-lock/deadlock scenarios.

Bryan Crosby
  • 6,486
  • 3
  • 36
  • 55
0

No, that's not going to be a problem... you're only locking your own worker process only. Other tasks have their process. While locks are useful for specific tasks I'd recommend you keep them to a minimum since you'll introduce waits in your application.

Asken
  • 7,679
  • 10
  • 45
  • 77