freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

[計(jì)算機(jī)]platform設(shè)備的添加流程(編輯修改稿)

2025-09-13 03:56 本頁面
 

【文章內(nèi)容簡介】 happens, and the conflicting resources425 * entirely fit within the range of the new resource, then the new426 * resource is inserted and the conflicting resources bee children of427 * the new resource.428 */429int insert_resource(struct resource *parent, struct resource *new)430{431 struct resource *conflict。432433 write_lock(amp。resource_lock)。434 conflict = __insert_resource(parent, new)。435 write_unlock(amp。resource_lock)。436 return conflict ? EBUSY : 0。437}資源鎖resource_lock對所有資源樹進(jìn)行讀寫保護(hù),任何代碼段在訪問某一顆資源樹之前都必須先持有該鎖,該鎖的定義也在 。鎖機(jī)制我們暫且不管,該函數(shù)里面關(guān)鍵的就是__insert_resource()函數(shù):// kernel/:365/*366 * Insert a resource into the resource tree. If successful, return NULL,367 * otherwise return the conflicting resource (pare to __request_resource())368 */369static struct resource * __insert_resource(struct resource *parent, struct resource *new)370{371 struct resource *first, *next。372373 for (。 parent = first) {374 first = __request_resource(parent, new)。375 if (!first)376 return first。377378 if (first == parent)379 return first。380381 if ((firststart newstart) || (firstend end))382 break。383 if ((firststart == newstart) amp。amp。 (firstend == newend))384 break。385 }386387 for (next = first。 。 next = nextsibling) {388 /* Partial overlap? Bad, and unfixable */389 if (nextstart start || nextend newend)390 return next。391 if (!nextsibling)392 break。393 if (nextsiblingstart newend)394 break。395 }396397 newparent = parent。398 newsibling = nextsibling。399 newchild = first。400401 nextsibling = NULL。402 for (next = first。 next。 next = nextsibling)403 nextparent = new。404405 if (parentchild == first) {406 parentchild = new。407 } else {408 next = parentchild。409 while (nextsibling != first)410 next = nextsibling。411 nextsibling = new。412 }413 return NULL。414}374行有個(gè)__request_resource(),它完成實(shí)際的資源分配工作。如果參數(shù)new所描述的資源中的一部分或全部已經(jīng)被其它節(jié)點(diǎn)所占用,則函數(shù)返回與new相沖突的resource結(jié)構(gòu)的指針。否則就返回NULL。該函數(shù)的源代碼如下:// kernel/:142/* Return the conflict entry if you can\t request it */143static struct resource * __request_resource(struct resource *root, struct resource *new)144{145 resource_size_t start = newstart。146 resource_size_t end = newend。147 struct resource *tmp, **p。148149 if (end start)152 return root。153 if (end rootend)154 return root。155 p = amp。rootchild。156 for (。) {157 tmp = *p。158 if (!tmp || tmpstart end) {159 newsibling = tmp。160 *p = new。161 newparent = root。162 return NULL。163 }164 p = amp。tmpsibling。165 if (tmpend sibling。For循環(huán)體的執(zhí)行步驟如下:(1)讓tmp指向當(dāng)前正被掃描的resource結(jié)構(gòu)(tmp=*p)。(2)判斷tmp指針是否為空(tmp指針為空說明已經(jīng)遍歷完整個(gè)child鏈表),或者當(dāng)前被掃描節(jié)點(diǎn)的起始位置start是否比new的結(jié)束位置end還要大。只要這兩個(gè)條件之一成立的話,就說明沒有資源沖突,于是就可以把new鏈入child鏈表中:①設(shè)置new的sibling指針指向當(dāng)前正被掃描的節(jié)點(diǎn)tmp(newsibling=tmp);②當(dāng)前節(jié)點(diǎn)tmp的前一個(gè)兄弟節(jié)點(diǎn)的sibling指針被修改為指向new這個(gè)節(jié)點(diǎn)(*p=new);③將new的parent指針設(shè)置為指向root。然后函數(shù)就可以返回了(返回值NULL表示沒有資源沖突)。(3)如果上述兩個(gè)條件都不成立,這說明當(dāng)前被掃描節(jié)點(diǎn)的資源域有可能與new相沖突(實(shí)際上就是兩個(gè)閉區(qū)間有交集),因此需要進(jìn)一步判斷。為此它首先修改指針p,讓它指向tmpsibling,以便于繼續(xù)掃描child鏈表。然后,判斷tmpend是否小于newstart,如果小于,則說明當(dāng)前節(jié)點(diǎn)tmp和new沒有資源沖突,因此執(zhí)行continue語句,繼續(xù)向下掃描child鏈表。否則,如果tmpend大于或等于newstart,則說明tmp[start,end]和new[start,end]之間有交集。所以返回當(dāng)前節(jié)點(diǎn)的指針tmp,表示發(fā)生資源沖突。繼續(xù)回到platform_device_add()函數(shù)里面,如果insert_resource()成功,下一步就會(huì)調(diào)用280行device_add()函數(shù)來將設(shè)備添加到設(shè)備樹里面。這個(gè)函數(shù)暫且不做分析。+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++3 platform_driver驅(qū)動(dòng)的注冊過程,一般分為三個(gè)步驟:定義一個(gè)platform_driver結(jié)構(gòu)platform_device對應(yīng)的驅(qū)動(dòng)是struct platform_driver,它的定義如下// include/linux/:48struct platform_driver {49 int (*probe)(struct platform_device *)。50 int (*remove)(struct platform_device *)。51 void (*shutdown)(struct platform_device *)。52 int (*suspend)(struct platform_device *, pm_message_t state)。53 int (*suspend_late)(struct platform_device *, pm_message_t state)。54 int (*resume_early)(struct platform_device *)。55 int (*resume)(s
點(diǎn)擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1