亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2636 | 回復(fù): 4
打印 上一主題 下一主題

請教Serializing Tokens的含義 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2006-09-02 16:57 |只看該作者 |倒序瀏覽
看文檔的時候看到這樣一個詞Serializing Tokens ,不能理解是什么意思,

A thread may hold any number of serializing tokens.

A thread may hold serializing tokens through a thread yield or blocking condition, but must understand that another thread holding those tokens may be allowed to run while the first thread is not running (blocked or yielded away).

[ 本帖最后由 japonensis 于 2006-9-2 16:59 編輯 ]

論壇徽章:
0
2 [報告]
發(fā)表于 2006-09-02 16:58 |只看該作者
搜索了一下也沒有看到中文的解釋,字面意思直譯不知道怎么樣。串行標(biāo)記?

論壇徽章:
2
亥豬
日期:2014-03-19 16:36:35午馬
日期:2014-11-23 23:48:46
3 [報告]
發(fā)表于 2006-09-02 17:29 |只看該作者
Copied entirely from http://en.wikipedia.org/wiki/Serializing_tokens

In computer science, serializing tokens are a concept in concurrency control arising from the ongoing development of DragonFly BSD. According to Matt Dillon, they are most akin to SPLs, except a token works across multiple CPUs while SPLs only work within a single CPU's domain.

Serializing tokens allow programmers to write multiprocessor-safe code without themselves or the lower level subsystems needing to be aware of every single entity that may also be holding the same token.

Tokens vs. Mutexes

Tokens are similar to mutexes in that they can, if used correctly, prevent multiple threads from accessing a shared resource at the same time. Unlike mutexes, however, they do NOT exclude other threads from accessing the resource while they are blocked or asleep. In general terms, they're both locks: your thread gets a lock (which prevents other threads from having it), does some work, and then releases it for another thread to use.

It's important here to recall how threads interact with each other when sharing resources. There are a number of ways that a thread can be stopped and another thread to be started:

     1. Timeslicing: the scheduler tries to ensure that all threads get a fair chance to run, so it runs each thread for a brief period of time (a timeslice) and then switches to another thread.
     2. Concurrent Execution: In multiprocessor computers, your thread may also be run at exactly the same time as another thread on a different CPU.
     3. Preemption: A thread may be preempted by a higher priority thread, such as a hardware interrupt or LWKT.
     4. Voluntary Blocking: A thread may voluntarily block (aka "go to sleep" ) if it has to wait for something, has no work to do, or calls a function that blocks-- note that even the call to acquire a lock can block.

Remember: the purpose of a lock is to keep other threads out while your thread is working on something. This table summarizes the situations in which tokens and mutexes work correctly to keep other threads "out".



So what's the big deal? It seems like mutexes are the clear winner-- and in some cases it's important to be able to block and keep a lock. However, they also cause problems such as Deadlocks and Priority inversions. Dealing with these issues is very difficult and requires coordination at many different levels of the kernel:
   "In fact, the fact that tokens do not deadlock coupled with the fact
   that there is no expectation of atomicity for earlier acquired tokens
   when later operations block leads to a great deal of code simplification.
   If you look at FreeBSD-5, you will notice that FreeBSD-5 passes held
   mutexes down the subroutine stack quite often, in order to allow some
   very deep procedural level to temporarily release a mutex in order to
   switch or block or deal with a deadlock.  There is a great deal of
   code pollution in FreeBSD-5 because of this (where some procedures
   must be given knowledge of the mutexes held by other unrelated procedures
   in order to function properly)." -- Matt Dillon

Obviously Matt has reason to promote his own solution to deadlocking, but he has a point: serializing tokens do a fine job of locking out other threads as long as you don't block while holding them. If you do, another thread will steal the lock and possibly change the data you were working on. You will reacquire the token when you are awakened, but you will have to make sure that your data is still consistent.

Serializing Tokens In Action

To show how serializing tokens actually work, let's see some pseudocode and what's going on behind the scenes.



References
A mailing list thread where Matt Dillon explains tokens in great detail

[ 本帖最后由 gvim 于 2006-9-2 17:31 編輯 ]

論壇徽章:
2
亥豬
日期:2014-03-19 16:36:35午馬
日期:2014-11-23 23:48:46
4 [報告]
發(fā)表于 2006-09-02 17:37 |只看該作者
看了wiki的說明和部分郵件,我感覺有點像令牌環(huán)那么個東西。

論壇徽章:
0
5 [報告]
發(fā)表于 2006-09-04 08:47 |只看該作者
這是df的同步手段吧.應(yīng)該是防止死鎖的.死鎖的一個必要條件是xxx環(huán)路,使用這種串行后無法形成環(huán)路,確保沒有死鎖,似乎是如此.
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP