[ad_1]
Create a global mutex, this will help us to identify if another instance of the same application is running, this is needed as its inter process communication. 3. Start a thread which runs continuously with a sleep of 1 sec and write "Worker thread running" onto the console. The while will be running on flag. 4. After starting the thread wait on a global event. 5. If global event is acquired, which means another instance as set this event. Set the flag at Step 3 so that the worker thread exists. 6. When passed command line is "stop" then open the event in Step 4 and set the event. Requirement 1: Create a C++ console application which takes the below command line argument, \action: "start" Once the start command line is passed, just run the while loop with a delay of 1 sec and write some console on each interval Example: while() { sleep(1000); } Requirement 2: The same application while running should be capable to receive command line arguments like the below, \action: "stop" When this command line, should break the above while loop, write the console log and exit.is sent
私が試したこと:
I'm not well trained in C++ programming, but as a part of a company's recruitment process, I was asked to complete this task in C++, I understand how to use a mutex to prevent additional instances loading, but that doesn't quite solve my problem. I tried finding solutions but I was too much of a beginner to understand these mutex concepts, I'm having a deadline fast approaching, if anyone can solve it out, It will be very useful for me!
解決策 1
自分でタスクを完了できない場合は、この会社が求めているレベルの経験がないことは明らかです。 ここの誰かがあなたに完全な解決策を提供し、あなたが仕事を得たとしたら、どうしますか? 彼らがあなたに本当の仕事を与えられたとき、あなたは何をしますか?
[ad_2]
コメント