在EXEC调用中,我希望通过删除父进程的内存来创建内存来允许更大的"子进程".
我正在使用MINIX 3.2并计划修改exec.c
以调用alloc_new_mem
in 的修改版本alloc.c
以下是alloc.c的源代码 - https://github.com/minix3/minix/blob/master/servers/vm/alloc.c
寻找指针.
操作系统:MINIX3文件:alloc.c
我正在尝试在 Minix 上创建一个字符设备驱动程序。我希望它能够接受read()
和write()
调用。我的理解是,我需要sys_safecopyfrom()
用于运行该read()
函数的函数和sys_safecopyto()
运行该write()
函数的函数。问题是当我像这样运行它时,我不断收到类似的错误(虽然不完全相同,但我认为差异在于内存位置)。错误是:
verify_grant: grant verify failed: access invalid: want 0x..., have 0x...
grant 2 verify to copy ... -> ... by ... failed err -1
read: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
“...”是内存位置,除了内存位置之外,写入的错误类似,并且在最后一行显示“写入”而不是“读取”。
我认为相关代码如下:
#include <minix/drivers.h>
#include <minix/chardriver.h>
#include <stdio.h>
#include <stdlib.h>
#include <minix/ds.h>
...
static struct chardriver hello_tab =
{
.cdr_open = hello_open,
.cdr_close = hello_close,
.cdr_read = hello_read,
.cdr_write = hello_write,
};
...
static ssize_t hello_read(devminor_t UNUSED(minor), u64_t …
Run Code Online (Sandbox Code Playgroud) 我在更大的C程序中有以下代码.刚才我尝试编译时没有任何问题; 它在Minix 2.0.4中运行并使用编译cc
.编译错误如下所示:
line 26: void not expected
Run Code Online (Sandbox Code Playgroud)
第26行只是一个函数声明main()
:
void initpool(void);
Run Code Online (Sandbox Code Playgroud)
initpool()
本身稍后在程序中使用此标头定义:
void
initpool(void)
{
Run Code Online (Sandbox Code Playgroud)
从我研究过的一切都应该是正确的,并gcc
没有抛出编译错误.之前的所有行都以;
s应该结束,所以这不是问题.为什么要cc
编译它有问题?
编辑:根据要求,通向第26行的行如下(从main()
第25行开始,第25行为空):
19: int
20: main(int argc, char *argv[])
21: {
22: int count, inserror;
23: olnode *list, *ptr;
24: list = NULL;
Run Code Online (Sandbox Code Playgroud) 当在类似Unix的操作系统(即MINIX 3)中运行的程序中使用fork()函数时,它会创建一些独立的进程,这些进程可以独立处理,因此可以相互提前完成(这实际上就是我想要)或者它会创建一系列顺序过程,这些过程只按照创建的顺序完成.
这是我用来fork()的代码
for(j = 0; j < num_fork_loops;) {
if (fork() < 0) {
printf("Fork has failed\n");
exit(EXIT_FAILURE);
}
j++;
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间
我正在尝试在 Minix 3.3 中创建一个新的系统调用。起初我只想创建简单的 printmsg() 调用,它将在屏幕上写下“Hello World”。
我在互联网上查看了各种教程,但仍然找不到解决方案。
我像这样在callnr.h 中定义了我的 sys call number#define PM_PRINTMSG (PM BASE + 48)
并且我增加了 sys call 的数量#define NR_PM_CALLS 49
。
在table.c 中,我添加了CALL(PM_PRINTMSG) = doprintmsg
.
在proto.h 中,我描述了函数原型 `int do_printmsg(void);
函数实现是用misc.c编写的。我添加#include <stdio.h>
并制作了 Hello World 功能int do printmsg(){ printf("I am a system call"); return 0; }
当我在用户程序中测试我的系统调用时,_syscall(PM_PROC_NR, PM_PRINTMSG, &m);
我没有收到任何错误,但没有显示 printf。
那么,是否可以从系统调用<stdio.h>
中打印消息,因为我必须将自己添加到misc.c 中或者我错过了一些步骤。我忘了提到我进入 /usr/src/releasetoolsmake services …
我正在尝试学习操作系统的工作方式。这是我要解决的一个容易的任务:编写一个简单的引导程序,提示用户输入他的名字并打印欢迎消息,例如“ hello,>> name <<”-之后,它什么也不做。
如果minix 3
与qemu
此相关,我正在与一起运行。我只是将asm
文件dd
及其前512个字节编译为/dev/c0d0
(的虚拟硬盘minix
)。
我可以打印消息并打印用户输入的内容。但是,此后我没有设法打印用户名。
这是我的汇编代码:
[bits 16]
[org 0x7c00]
mov si, HelloString
call print_string
mov di, name
call read_name
mov si, name
call print_string
read_name:
read_char:
mov ah, 0h ; read character from keyboard
mov [di], ah ; save it in the buffer
inc di ; next char
int 0x16 ; store it in AL
cmp ah, 0x0d ; check for enter
je stop_reading
mov …
Run Code Online (Sandbox Code Playgroud) 首先,我在谈论类UNIX系统.
我看一下Mac OS,Linux,Minix和K&R C书中"FILE"结构的定义,它们都是不同的.
在K&R C书中,很清楚
typedef struct _iobuf{
int cnt;
char *ptr;
char *base;
int flag;
int fd;
} FILE;
Run Code Online (Sandbox Code Playgroud)
在Mac OS上,它在结构中有更多东西.
在Linux(3.0)上,它是
typedef _IO_FILE FILE;
Run Code Online (Sandbox Code Playgroud)
标题显示"在C++ iostreams之上定义ISO C stdio".嗯...?(Linux上的C是用C++实现的吗?不应该相反吗?)看起来_IO_FILE定义在libio.h中
在Minix上,定义与K&R非常相似.
我的unstanding是stdio.h应该是C的一部分.第一个C编译器是用汇编语言实现的.并且C应该独立于OS类型.
HW上的机器代码 - > asm - > C - >更复杂的C - > UNIX
现在,在不同的操作系统(各种UNIX)上有不同的stdio.h,编译器都是gcc.
怎么理解这个?
非常感谢,阿尔弗雷德
我已经下载了MINIX 3操作系统,并在Mac pro的并行桌面上运行它。MINIX3是一个.iso文件,我想知道如何编写一些程序并将其打包到.iso文件中。并通过虚拟机(Parallels Desktop)运行它?
我该怎么办?
我是一名Android开发人员。
我需要在屏幕上打印一行,然后获取用户输入,但这些printf("blah")
语句导致我的代码无法编译。错误消息说'char not expected'但是当我注释掉这些printf()
语句时,代码就会编译。
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Welcome to the shell!\n");
printf("shell:>");
char* inp = (char*)malloc(20); // error at this line
}
Run Code Online (Sandbox Code Playgroud)
我在 MINIX 3.1.0 中使用 cc 编译器
我想在 MINX 3 中使用-fopenmp
,当我写下命令时:
gcc -fopenmp test.c -o test.out
它显示了这个错误:
cc1:错误:无法识别的命令行选项“-fopenmp”
我使用的 Minix 3 的 GCC 版本是 GCC 4.1.1。我必须使用旧版本的 Minix,这是它拥有的唯一版本的 GCC。
难道问题是GCC的版本没有-fopenmp
??
我正在尝试cat
在MINIX 3.2.1中修改命令,但遇到一些问题。我想添加-H
标志,以便在使用它时,在文件名之前打印文件名。我在cat.c中添加了一些代码(指原始行的编号):
第64行(Hflag
变量):
int Hflag, bflag, eflag, fflag, lflag, nflag, sflag, tflag, vflag;
Run Code Online (Sandbox Code Playgroud)
第85行(“ H”案):
case 'H':
Hflag = 1;
break;
case 'b':
Run Code Online (Sandbox Code Playgroud)
第130行(Hflag参数):
if (Hflag || bflag || eflag || nflag || sflag || tflag || vflag)
Run Code Online (Sandbox Code Playgroud)
Line 142 (added fprintf
to ensure that cat.c
was indeed added to recompiled MINIX):
fprintf(stdout, "new line\n");
FILE *fp;
Run Code Online (Sandbox Code Playgroud)
Line 157 (line that should print file name):
fprintf(stdout, "%s\n", *argv);
filename = *argv++;
Run Code Online (Sandbox Code Playgroud)
The problem is …