0
두 개의 프로세스 (프로세스 1과 2)를 수행하는 방법을 이해할 수 없으면 개별 실행 파일과 교환 메시지가 구현됩니다. 뭔가 (1.Hello 2.Hi 1. 어떻게 지내세요? ...).두 개의 실행 파일 (.dis) 파일이있는 두 개의 스레드 림보 (프로그래밍 언어)
아래 코드는 두 스레드가 텍스트 파일에서 메시지를 교환하는 방법을 보여줍니다. 텍스트 파일 대신에 서로 통신하는 실행 파일 (.dis)이 필요합니다.
implement LThread;
include "sys.m";
include "bufio.m";
include "draw.m";
sys:Sys;
FD: import Sys;
stOut: ref Sys->FD;
bufio:Bufio;
Iobuf:import bufio;
LThread:module{
init: fn(nil: ref Draw->Context, nil: list of string);
process: fn(pName: string);
};
init(nil: ref Draw->Context, nil: list of string) {
sys=load Sys Sys->PATH;
bufio=load Bufio Bufio->PATH;
spawn process("processA.txt");
sys->sleep(10);
spawn process("processB.txt");
}
process(pName: string) {
file_buf:ref Iobuf;
file_buf = bufio->open(pName, sys->ORDWR);
temp_line:string;
temp_line=" ";
while (temp_line != nil){
temp_line=file_buf.gets('\n');
sys->sleep(200);
sys->print("%s \n",temp_line);
}
}
아마도 모듈을 사용하여 잘 모르겠습니다.
코드에는 2 개의 프로세스가 구현되어 있으며 처리 방법을 알아야합니다. 당신은 그 코드가 2 개의 스레드를 보여 주며 거기에 2 개의 프로세스가 있다는 것을 알 수 있습니다. 코드가하는 일과 당신의 문제는 무엇인지 구체적으로 말할 수 있습니까? – Lucian
2 개의 실행 파일 중 2 개의 프로세스를 호출해야하며이 프로세스가 병렬로 작동해야합니다. 실행 파일을 호출하는 방법을 모르겠습니다. – Gleb