English 中文(简体)
平行接触物体组
原标题:Concurrent access to groups of objects

I m试图开发一种由校对组成的申请,利用工作-教学法同时执行任务。

这些任务

  • access a predefined set of objects;
  • must "atomicly" acquire read/write permissions on all objects it accesses before actually running;
  • upon finishing (and are guaranteed to eventually finish) release the objects they acquire.

解决这一问题的一个可能途径是让每一个物体在某个时候完成一项任务,然后尝试用预先界定的命令锁定每个物体。 如果至少有一人未能释放所有锁,并着手执行另一项任务。

然而,这种方法增加了与大物体受抚养者交织任务的可能性,甚至可能出现活锁。

Is there another method to acquire a set of locks while maximizing concurrency? (without a global lock) Or perhaps change the system in a way that it is no longer required? If so, any good papers about it?

<>光> 正如该州回答的那样,这是“哲学家”问题的一个普遍版本。 我正在寻求非集中化的解决办法,特别是高负荷(重任和删除任务)的算法。

最佳回答
问题回答

配置资源是一种有效的办法。 另一个直截了当的教程是引入一个共同的仲裁员,掌握关于资源可用性的信息。 任务将锁定他们通过仲裁员在一个单一的原子步骤“查询(r1, r2, ......, rn)”上所需要的一切资源,并将这些资源与“release(r1, r2, ......, rn)”相类似。

如果能够满足“要求”A的要求,仲裁员将保证在A将其释放之前不会获得A所持有的任何资源。

仲裁员可使用若干战略满足下列要求:

  1. Reject request that can t be immediately satisfied - tasks will have to re-try. This opens the door to live-locks and starvation.
  2. Keep all incoming requests in a queue and serving them in FIFO manner as resources needed for the request at head become available.
  3. Keep all unsatisfied requests in a list (without blocking their demanded resources) and iterate through them (perhaps with a priority for older requests) each time some resources get released, to find a request that can be satisfied.

如果一项任务只试图锁定目标,在某个时候失败,那么另一项任务可能无法锁定目标,因为第一项任务当时拥有它。

我认为,在试图最初获得锁时,我会使用一个全球锁,在最后放行这些锁时也可能使用。

我担心,如果简单的解决办法在实践中证明不够充分,那么这种最大限度的一致。





相关问题
Need help with web application settings [closed]

Pls give me the solutions for this two problem, which i was asked recently in interview. Prob1: Suppose I have application with 10 admin, so they can change the data anytime their having own userid ...

AutoResetEvent, ManualResetEvent vs Monitor

Lets say I have to orchestrate a synchronization algorithm in .Net 3.5 SP1 and any of the synchronization primitives listed in the title fit perfectly for the task. From a performance perspective, is ...

PHP and Concurrency

I ve been doing some web development work in PHP recently which has led me to study up on the language in general. So far I have not needed to use it to interact with a database, but I know it ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

Prevent Concurrent Editing of a List Item

In Sharepoint MOSS multiple users can edit the same item in a sharepoint list at the same time…the first person to save their edit “wins”. Is there a way to prevent this, to lock the list item while ...

How to properly catch RuntimeExceptions from Executors?

Say that I have the following code: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(myRunnable); Now, if myRunnable throws a RuntimeExcpetion, how can I catch it? ...

Concurrent modification whilst traversing a ruby Hash

Suppose you had this: def wipeProduct(hash, nameToDelete) hash.each do |i| key = i[0] productName = i[1].first hash.delete(key) if productName==nameToDelete end end I m not sure it ...

热门标签