QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1433|回复: 1

0.11的make_request

[复制链接]
发表于 2005-9-6 20:57:34 | 显示全部楼层 |阅读模式
大家好!
我读0.11kernel/blk_drv/ll_rw_blk.c的时候有点疑问:
这里查找的时候没有关中,如果这个时候被中断,在别的任务里面做了修改,肯定会对本任务的查找有影响啊。比如,找到一个空slot,结果中断,另一任务中也找到该slot并且修改该slot,等调度回来的时候不就崩了吗?

static void make_request(int major,int rw, struct buffer_head * bh)
{
        struct request * req;
        int rw_ahead;

/* WRITEA/READA is special case - it is not really needed, so if the */
/* buffer is locked, we just forget about it, else it's a normal read */
        if (rw_ahead = (rw == READA || rw == WRITEA)) {
                if (bh->b_lock)
                        return;
                if (rw == READA)
                        rw = READ;
                else
                        rw = WRITE;
        }
        if (rw!=READ && rw!=WRITE)
                panic("Bad block dev command, must be R/W/RA/WA");
        lock_buffer(bh);
        if ((rw == WRITE && !bh->b_dirt) || (rw == READ && bh->b_uptodate)) {
                unlock_buffer(bh);
                return;
        }
repeat:
/* we don't allow the write-requests to fill up the queue completely:
* we want some room for reads: they take precedence. The last third
* of the requests are only for reads.
*/
        if (rw == READ)
                req = request+NR_REQUEST;
        else
                req = request+((NR_REQUEST*2)/3);
/* find an empty request */
        while (--req >= request)
                if (req->dev<0)
                        break;
/* if none found, sleep on new requests: check for rw_ahead */
        if (req < request) {
                if (rw_ahead) {
                        unlock_buffer(bh);
                        return;
                }
                sleep_on(&wait_for_request);
                goto repeat;
        }
/* fill up the request-info, and add it to the queue */
        req->dev = bh->b_dev;
        req->cmd = rw;
        req->errors=0;
        req->sector = bh->b_blocknr<<1;
        req->nr_sectors = 2;
        req->buffer = bh->b_data;
        req->waiting = NULL;
        req->bh = bh;
        req->next = NULL;
        add_request(major+blk_dev,req);
}
发表于 2005-9-22 21:13:11 | 显示全部楼层

Re: 0.11的make_request

0.11的内核代码应该不会被抢占吧

[quote:e58d065eae="gpmn"]大家好!
我读0.11kernel/blk_drv/ll_rw_blk.c的时候有点疑问:
这里查找的时候没有关中,如果这个时候被中断,在别的任务里面做了修改,肯定会对本任务的查找有影响啊。比如,找到一个空slot,结果中断,另一任务中也找到该slot并且修改该slot,等调度回来的时候不就崩了吗?
[/quote]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-1 04:36 , Processed in 0.129893 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表