How to suspend and resume a Process and Thread in C++ [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i wan't to suspend and resume main function is there any way except sleep method. Please Help

Assuming you have other threads running apart from main, you can use use a sem_wait (semaphore initialized to 0) in main() and then from your thread you can call sem_post whenever you want main() to run.
Read about semaphore and usage:

Related

Thread waiting until a condition is true or a timeout occurs C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I have a thread that must wait until a condition is true or until a timer runs out and I was thinking which would be the best way to solve it, I though about condition variables but I am not sure if is the best method since I could have race condition, I would be happy to hear your suggestion.
Thank you.
A simple way is to have a locked mutex that your thread can wait for. Your timer can then unlock the mutex when you want the thread to continue.

Origins of "joinable" and "unjoinable" in multi-threading [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Why does POSIX use the words "joinable" and "unjoinable" to describe between a thread that is/was/might/could-in-the-future-be doing something and a thread that is idle and waiting to be deleted? What was the initiative behind the selection of these particular words to describe the current state of a thread?
You can maybe use this kind of mental model to explain the terminology:

Notify a specified tread in C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I didn't find anything on the Internet about this, so I'm asking here.
Is there a command in C++ to notify a specified thread and not a casual one?
Use one std::condition_variable for each event you want to wait for.

Shutdown curent thread C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Edited.
How to shutdown(to stop it forever) current thread in a class method?
Now, I have:
methodName() {
std::unique_lock<std::mutex> locker(...);
cv.wait(locker, [this]{return ready_ || finished_;});
if (finished_) //need to terminate cur thread
...
}
The question isn't that clear, but if you are working on windows, you cant shut any thread down using TerminateThread or if you want to close current thread, you could use CloseThread.

Catching informations about running processes in Windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My task is to make a program, which counts a time of running processes in windows. Can you suggest me how or from where can I catch that informations?
For list of currently running processes under Windows use EnumProcesses win32 API
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682629%28v=vs.85%29.aspx
example how to do this:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682623%28v=vs.85%29.aspx
From your question I'm not sure if you need process timing information (CPU time,etc.) or to count instances of given process in memory. Could you please explain this more clearly ?
You can use GetProcessTimes function to get process timing information.