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

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 6996 | 回復(fù): 6
打印 上一主題 下一主題

mm_struct 中的 mm_count 和 mm_users ? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-03-24 21:22 |只看該作者 |倒序?yàn)g覽
mm_struct 中的 mm_count 和 mm_users 有什么不同? 分別用于什么場(chǎng)合? 為什么有這樣的設(shè)計(jì)呢?
望高人指教呀~

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2009-03-24 21:37 |只看該作者
原帖由 kouu 于 2009-3-24 21:22 發(fā)表
mm_struct 中的 mm_count 和 mm_users 有什么不同? 分別用于什么場(chǎng)合? 為什么有這樣的設(shè)計(jì)呢?
望高人指教呀~


ULK上面有解釋的:
The mm_users field stores the number of lightweight processes that share the mm_struct data structure (see the section "The clone( ), fork( ), and vfork( ) System Calls" in Chapter 3). The mm_count field is the main usage counter of the memory descriptor; all "users" in mm_users count as one unit in mm_count. Every time the mm_count field is decreased, the kernel checks whether it becomes zero; if so, the memory descriptor is deallocated because it is no longer in use.

We'll try to explain the difference between the use of mm_users and mm_count with an example. Consider a memory descriptor shared by two lightweight processes. Normally, its mm_users field stores the value 2, while its mm_count field stores the value 1 (both owner processes count as one).

If the memory descriptor is temporarily lent to a kernel thread (see the next section), the kernel increases the mm_count field. In this way, even if both lightweight processes die and the mm_users field becomes zero, the memory descriptor is not released until the kernel thread finishes using it because the mm_count field remains greater than zero.

If the kernel wants to be sure that the memory descriptor is not released in the middle of a lengthy operation, it might increase the mm_users field instead of mm_count (this is what the try_to_unuse( ) function does; see the section "Activating and Deactivating a Swap Area" in Chapter 17). The final result is the same because the increment of mm_users ensures that mm_count does not become zero even if all lightweight processes that own the memory descriptor die.

The mm_alloc( ) function is invoked to get a new memory descriptor. Because these descriptors are stored in a slab allocator cache, mm_alloc( ) calls kmem_cache_alloc( ), initializes the new memory descriptor, and sets the mm_count and mm_users field to 1.

Conversely, the mmput( ) function decreases the mm_users field of a memory descriptor. If that field becomes 0, the function releases the Local Descriptor Table, the memory region descriptors (see later in this chapter), and the Page Tables referenced by the memory descriptor, and then invokes mmdrop( ). The latter function decreases mm_count and, if it becomes zero, releases the mm_struct data structure.

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2009-03-24 22:47 |只看該作者
多謝ls的回答。總算看明白了~
初始狀態(tài)下,這兩個(gè)值都是1。當(dāng) mm_users 減為 0 時(shí),mm_count 會(huì)自減 1。也即是僅當(dāng) mm_users 減為 0 時(shí),mm_count 才可能為 0。
mm_count 代表了對(duì) mm 本身的引用,而 mm_users 代表對(duì) mm 相關(guān)資源的引用,分了兩個(gè)層次。
可能存在這樣的情況,mm 已經(jīng)沒(méi)有人使用了(mm_users為0),所以其相關(guān)資源被釋放掉(如vma);但是 mm 本身可能還在被人使用(比如被一個(gè)內(nèi)核線程,它不會(huì)使用vma),所以 mm 本身還不能被釋放;
這個(gè)理解應(yīng)該沒(méi)錯(cuò)吧?

論壇徽章:
16
2015亞冠之吉達(dá)阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉雞
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52雙魚(yú)座
日期:2014-02-22 13:07:56午馬
日期:2014-02-14 11:08:18雙魚(yú)座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
4 [報(bào)告]
發(fā)表于 2011-08-17 09:54 |只看該作者
mm_count是主使用計(jì)數(shù),mm_users是共享mm_struct的進(jìn)程數(shù),mm_users中的所有用戶在mm_count中只作為一個(gè)單位

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2011-08-20 16:26 |只看該作者
mm_count類似于 以進(jìn)程為單位。  mm_users類似于以線程為單位。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2011-08-20 19:27 |只看該作者
恩。我當(dāng)初對(duì)這個(gè)也有疑問(wèn)。

Thanks above all.

論壇徽章:
16
2015亞冠之吉達(dá)阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉雞
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52雙魚(yú)座
日期:2014-02-22 13:07:56午馬
日期:2014-02-14 11:08:18雙魚(yú)座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
7 [報(bào)告]
發(fā)表于 2011-08-31 16:53 |只看該作者
5樓的很透徹
您需要登錄后才可以回帖 登錄 | 注冊(cè)

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

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP