thread questino

This is a discussion on thread questino within the C++ Programming forums, part of the General Programming Boards category; I am doing a real-time project. Under windows and linux(program is not necessary portable, we could turn in two versions) ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    9

    Question thread questino

    I am doing a real-time project. Under windows and linux(program is not necessary portable, we could turn in two versions)
    I need to measure the context switch time between two threads.

    I remember there is a systemcall like "sleep", which could put a thread to sleep then another one will own the cpu.(if you know about the "sleep" like syscall pliz tell me the name)but I don;t know how to discriminate the other thread from the main process.
    how can I know which one will take the CPU after the first thread sleeps.

    Can I just create one thread and put it to sleep, then I will know for sure that the main process will own CPU. But is the result still the context switch time?


    Thanks, and sorry for my bad english. Hope you can understand me.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    9
    I found out that there is a sleep call in windows which can Suspends the current thread for a specified time. I think this solves my problem.

  3. #3
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719
    You can only create a suspended thread, then use ResumeThread to activate it. At least MSDN says there is only one way to suspend it, which is during creation, but you may find an alternative. IF you do, please tell me how you suspended the thread.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    You could use SuspendThread() and ResumeThread().

    Kuphryn

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    9
    Originally posted by Xei
    You can only create a suspended thread, then use ResumeThread to activate it. At least MSDN says there is only one way to suspend it, which is during creation, but you may find an alternative. IF you do, please tell me how you suspended the thread.
    Here is what I found on MSDN, thanks for your help

    http://msdn.microsoft.com/library/de...base/sleep.asp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 04:55 PM
  3. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 08:50 AM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 11:34 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 02:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21