Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
36ebee8f
提交
36ebee8f
1月 24, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove dead code in sched.c
上级
eca599b3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
104 行删除
+0
-104
sched.c
sched.c
+0
-104
没有找到文件。
sched.c
浏览文件 @
36ebee8f
...
@@ -130,107 +130,3 @@ initsched(void)
...
@@ -130,107 +130,3 @@ initsched(void)
STAILQ_INIT
(
&
runq
[
i
].
q
);
STAILQ_INIT
(
&
runq
[
i
].
q
);
}
}
}
}
#if 0
// XXX(sbw) This code is broken. It essentially implements "LIFO"
// scheduling, which leads to starvation and deadlock (in userspace).
struct ns *nsrunq __mpalign__;
// Mark a process RUNNABLE and add it to the runq
// of its cpu. Caller must hold p->lock so that
// some other core doesn't start running the
// process before the caller has finished setting
// the process up, and to cope with racing callers
// e.g. two wakeups on same process. and to
// allow atomic addrun(); sched();
void
addrun(struct proc *p)
{
#if SPINLOCK_DEBUG
if(!holding(&p->lock))
panic("addrun no p->lock");
#endif
if (p->on_runq >= 0)
panic("addrun on runq already");
ns_insert(nsrunq, KI(p->cpuid), p);
p->on_runq = p->cpuid;
}
void
delrun(struct proc *p)
{
#if SPINLOCK_DEBUG
if(!holding(&p->lock))
panic("delrun no p->lock");
#endif
if (p->on_runq < 0)
panic("delrun not on runq");
if (ns_remove(nsrunq, KI(p->on_runq), p) == 0)
panic("delrun: ns_remove");
p->on_runq = -1;
}
static void *
steal_cb(void *vk, void *v, void *arg)
{
struct proc *p = v;
acquire(&p->lock);
if (p->state != RUNNABLE || p->cpuid == mycpu()->id || p->cpu_pin) {
release(&p->lock);
return 0;
}
if (p->curcycles == 0 || p->curcycles > VICTIMAGE) {
if (sched_debug)
cprintf("cpu%d: steal %d (cycles=%d) from %d\n",
mycpu()->id, p->pid, (int)p->curcycles, p->cpuid);
delrun(p);
p->curcycles = 0;
p->cpuid = mycpu()->id;
addrun(p);
release(&p->lock);
return p;
}
release(&p->lock);
return 0;
}
int
steal(void)
{
void *stole = ns_enumerate(nsrunq, steal_cb, 0);
return stole ? 1 : 0;
}
static void *
choose_runnable(void *pp, void *arg)
{
struct proc *head = pp;
if (head->state == RUNNABLE)
return head;
return 0;
}
struct proc *
schednext(void)
{
// XXX(sbw) Yikes! If two processes are runnable on the same
// CPU this will always return to process addrun inserted last
// into the ns.
return ns_enumerate_key(nsrunq, KI(mycpu()->id), choose_runnable, 0);
}
void
initsched(void)
{
nsrunq = nsalloc(1);
if (nsrunq == 0)
panic("pinit runq");
}
#endif
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论