Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
bf390361
提交
bf390361
6月 26, 2006
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
system call arguments
上级
89eb5fbe
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
65 行增加
和
7 行删除
+65
-7
Makefile
Makefile
+1
-0
defs.h
defs.h
+1
-0
proc.c
proc.c
+1
-2
spinlock.c
spinlock.c
+3
-3
syscall.c
syscall.c
+40
-1
syscall.h
syscall.h
+1
-0
user1.c
user1.c
+18
-1
没有找到文件。
Makefile
浏览文件 @
bf390361
...
...
@@ -34,6 +34,7 @@ vectors.S : vectors.pl
user1
:
user1.c
$(CC)
-nostdinc
-I
.
-c
user1.c
$(LD)
-N
-e
main
-Ttext
0
-o
user1 user1.o
$(OBJDUMP)
-S
user1
>
user1.asm
-include
*.d
...
...
defs.h
浏览文件 @
bf390361
...
...
@@ -6,6 +6,7 @@ void kinit(void);
// console.c
void
cprintf
(
char
*
fmt
,
...);
void
panic
(
char
*
s
);
void
cons_putc
(
int
);
// proc.c
struct
proc
;
...
...
proc.c
浏览文件 @
bf390361
...
...
@@ -95,7 +95,6 @@ swtch()
struct
proc
*
np
;
struct
proc
*
op
=
curproc
[
cpu
()];
cprintf
(
"swtch cpu %d op %x proc0 %x
\n
"
,
cpu
(),
op
,
proc
);
while
(
1
){
np
=
op
+
1
;
while
(
np
!=
op
){
...
...
@@ -107,7 +106,7 @@ swtch()
}
if
(
np
->
state
==
RUNNABLE
)
break
;
cprintf
(
"swtch: nothing to run
\n
"
);
//
cprintf("swtch: nothing to run\n");
release_spinlock
(
&
kernel_lock
);
acquire_spinlock
(
&
kernel_lock
);
}
...
...
spinlock.c
浏览文件 @
bf390361
...
...
@@ -15,14 +15,14 @@ acquire_spinlock(uint32_t* lock)
if
(
*
lock
==
cpu_id
)
return
;
while
(
cmpxchg
(
LOCK_FREE
,
cpu_id
,
lock
)
!=
cpu_id
)
{
;
}
cprintf
(
"acquired: %d
\n
"
,
cpu_id
);
//
cprintf ("acquired: %d\n", cpu_id);
}
void
release_spinlock
(
uint32_t
*
lock
)
{
int
cpu_id
=
cpu
();
cprintf
(
"release: %d
\n
"
,
cpu_id
);
//
cprintf ("release: %d\n", cpu_id);
if
(
*
lock
!=
cpu_id
)
panic
(
"release_spinlock: releasing a lock that i don't own
\n
"
);
*
lock
=
LOCK_FREE
;
...
...
@@ -32,7 +32,7 @@ void
release_grant_spinlock
(
uint32_t
*
lock
,
int
c
)
{
int
cpu_id
=
cpu
();
cprintf
(
"release_grant: %d -> %d
\n
"
,
cpu_id
,
c
);
//
cprintf ("release_grant: %d -> %d\n", cpu_id, c);
if
(
*
lock
!=
cpu_id
)
panic
(
"release_spinlock: releasing a lock that i don't own
\n
"
);
*
lock
=
c
;
...
...
syscall.c
浏览文件 @
bf390361
...
...
@@ -10,11 +10,38 @@
/*
* User code makes a system call with INT T_SYSCALL.
* System call number in %eax.
* Arguments on the stack.
* Arguments on the stack, from the user call to the C
* library system call function. The saved user %esp points
* to a saved frame pointer, a program counter, and then
* the first argument.
*
* Return value? Error indication? Errno?
*/
/*
* fetch 32 bits from a user-supplied pointer.
* returns 1 if addr was OK, 0 if illegal.
*/
int
fetchint
(
struct
proc
*
p
,
unsigned
addr
,
int
*
ip
)
{
*
ip
=
0
;
if
(
addr
>
p
->
sz
-
4
)
return
0
;
memcpy
(
ip
,
p
->
mem
+
addr
,
4
);
return
1
;
}
int
fetcharg
(
int
argno
,
int
*
ip
)
{
unsigned
esp
;
esp
=
(
unsigned
)
curproc
[
cpu
()]
->
tf
->
tf_esp
;
return
fetchint
(
curproc
[
cpu
()],
esp
+
8
+
4
*
argno
,
ip
);
}
void
sys_fork
()
{
...
...
@@ -73,6 +100,15 @@ sys_wait()
}
void
sys_cons_putc
()
{
int
c
;
fetcharg
(
0
,
&
c
);
cons_putc
(
c
&
0xff
);
}
void
syscall
()
{
struct
proc
*
cp
=
curproc
[
cpu
()];
...
...
@@ -89,6 +125,9 @@ syscall()
case
SYS_wait
:
sys_wait
();
break
;
case
SYS_cons_putc
:
sys_cons_putc
();
break
;
default:
cprintf
(
"unknown sys call %d
\n
"
,
num
);
// XXX fault
...
...
syscall.h
浏览文件 @
bf390361
#define SYS_fork 1
#define SYS_exit 2
#define SYS_wait 3
#define SYS_cons_putc 4
user1.c
浏览文件 @
bf390361
...
...
@@ -5,9 +5,26 @@ fork()
asm
(
"int $48"
);
}
void
cons_putc
(
int
c
)
{
asm
(
"mov $4, %eax"
);
asm
(
"int $48"
);
}
void
puts
(
char
*
s
)
{
int
i
;
for
(
i
=
0
;
s
[
i
];
i
++
)
cons_putc
(
s
[
i
]);
}
main
()
{
fork
();
// fork();
puts
(
"hello!
\n
"
);
while
(
1
)
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论