Bài tập lớn–Hệ điều hành
**Đề bài: **Viết chương trình gồm 2 tiến trình. Tiến trình A đọc 1 dãy số nguyên từ một file,
sau đó gửi dãy số nguyên này cho tiến trình B thông qua cơ chế pipe. Tiến trình B sau khi
nhận xong dữ liệu từ tiến trình A sẽ sắp xếp theo thứ tự tăng dần rồi ghi vào 1 file khác.
Source: Client, Server (Tuấn + Hồng liên hệ t lấy password về nghiên cứu)
How to use: There are two ways to run these programs:
1
2
3
4
1. Run these programs directly by double click on them. Because this is the default way so you have to satisfy some requirements to make them run correctly. First, you must create a file name “server.txt” in D:\. Inside this file, you can type several numbers (maximum number of character is 250), they can be separated by a comma, or a space or whatever you want except numerical characters. Then, run the Server.exe, afterward execute the Client.exe. If everything OK, you will receive an announcement in the Client window that it has finished writing file on disc. And the location of result file will be D:\result.txt, otherwise you will get an error and the program terminates immediately.
2. The second approach is passing argument to these programs by command line. First, you have to specify the location where you place these files. Suppose, you put them in your desktop, so the location will be “C:\Users\_YourName_\Desktop\Server.exe” and “C:\Users\_YourName\_Desktop\Client.exe”. _**YourName** _here is your user name. First, open the command line window. You can change your directory to Desktop by typing “cd C:\Users\_YourName_\Desktop” and then type “Server.exe **_server.txt’s location_**”. The “**_server.txt’s location_**” is the directory of file server.txt. Remember that you are passing a string type argument so the backslash ‘\’ is a special character, so you have to add another ‘\’ for correct result. For example, I put my server.txt in E:\, so I will type in the command line window “Server.exe E:\\server.txt”. For Client.exe, it is similar that you can pass a string argument to specify the result.txt’s location. If you don’t specify the additional location for either Client.exe or Server.exe, the default directory will be used instead. And just like the first approach, another file will be created for saving sorted array of integers if everything ok.
The Server.exe doesn’t limit the number of clients to connect to it. So you can run as many Client.exe as you want. If I have time, I will make the User Interface for these programs. Thank for visiting my writing.
This post is licensed under
CC BY 4.0
by the author.
Comments powered by Disqus.