shell.c

来自「Nachos是个教学用的小型操作系统」· C语言 代码 · 共 45 行

C
45
字号
#include "nachos_syscall.h"intmain(){    SpaceId newProc;    OpenFileId input = ConsoleInput;    OpenFileId output = ConsoleOutput;    char prompt[2], ch, buffer[60];    int i;    prompt[0] = '-';    prompt[1] = '-';    Write("NachOS-SHELL ver 0.0\n", 21 ,output);    while( 1 )    {	Write(prompt, 2, output);	i = 0;		do {		    Read(&buffer[i], 1, input); 	} while( buffer[i++] != '\n' );	buffer[--i] = '\0';		if(strncmp(buffer,"exit", 4)==0) 		    /*		     * strncmp has to be replaced with your own 		     * implementation		     */	    Halt(); //stops the Simulation		if( i > 0 ) {	    newProc = Exec(buffer);	    Join(newProc);	}    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?