Home Help Center

Thread and Timer Questions (Windows 7, 64 bit)

billgbillg Member Bill GwOrganization: WMSProject: Games
These questions are with respect to running in a real-time environment (under Windows 7, 64-bit Embedded).

* What are the "int priority" value parameters for both the Timer and Thread classes (do these equate to Windows thread priority values?, an ICE defined enumeration?, is 1 low or high?, what is the range?, etc.) - I can't seem to find any documentation.

* It seems that the priority functions can only be used when running as an Administrator - is that true? (Otherwise trying to set the priority generates exceptions for both threads and timers.)

* However, running as an administrator, it seems like I can still generate exceptions when creating a timer (a priority of '5' worked, but '18' generated exception - but not always repeatable).

* What exactly is happening when the ICE priority is raised \ lowered? (Same as setting the thread priority in Windows via SetThreadPriorityAPI()?)

* Is it possible to raise \ lower the priority during thread execution?

* To run a periodic code function, which is more efficient (scheduler, overhead of system, etc.) \ would you recommend running an Ice thread and sleep() or a timer and scheduleRepeated()?

Thanks for the help.

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    What are the "int priority" value parameters for both the Timer and Thread classes (do these equate to Windows thread priority values?, an ICE defined enumeration?, is 1 low or high?, what is the range?, etc.) - I can't seem to find any documentation.
    The priority value is system-dependent; On Windows systems, the priority value is passed through to the Windows setThreadPriority function.

    see: Threads
    It seems that the priority functions can only be used when running as an Administrator - is that true? (Otherwise trying to set the priority generates exceptions for both threads and timers.)
    Running as an Administrator isn't necessary, have you try to run the priority test as non Administrator user? the test is in "cpp/test/IceUtil/priority" it should work with a normal User, do you get the same exceptions with the test? we have tested Windows 7 x64, but not Windows 7 x64 Embedded, maybe there is some differences in that OS version.
    * However, running as an administrator, it seems like I can still generate exceptions when creating a timer (a priority of '5' worked, but '18' generated exception - but not always repeatable).

    18 isn't a valid priority in windows, see here Scheduling Priorities (Windows)
    What exactly is happening when the ICE priority is raised \ lowered? (Same as setting the thread priority in Windows via SetThreadPriorityAPI()?)
    Yest Ice just call SetThreadPriority.
    Is it possible to raise \ lower the priority during thread execution?
    No, it isn't , you can just set the priority when start a thread, but it cannot be changed later.
    To run a periodic code function, which is more efficient (scheduler, overhead of system, etc.) \ would you recommend running an Ice thread and sleep() or a timer and scheduleRepeated()?
    You should use scheduleRepeated that is designed to run a periodic function, in general you should avoid using sleep.
  • billgbillg Member Bill GwOrganization: WMSProject: Games
    Thanks (and apologies ... I missed the part in the documentation where it said the priority is passed through to SetThreadPriority in Windows).

    I don't see any /cpp/test/IceUtil/ directory (or anything close to that) in my ICE install directory (3.4.1) and searched my hard drive and can't find the dir or executable. Do I need to install something else to get this utility?

    As for Administrator \ non-Administrator exceptions, the exception generated is "IceUtil::ThreadSyscallException" if that helps.
  • billgbillg Member Bill GwOrganization: WMSProject: Games
    FYI ... It looks like if I change the priority values to those defined in Windows documentation (THREAD_PRIORITY_TIME_CRITICAL, THREAD_PRIORITY_NORMAL, etc.) all seems fine in non-Admin. mode. Many apologies, if I had seen the Windows reference in the documentation the first time, I would have saved you the time on this one.

    All is fine - thanks again for the help.
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    The test suite is part of our source distributions, ZeroC - Download

    It Windows is better to use the constants THREAD_PRIORITY_TIME_CRITICAL, ...., when using numbers they depend on the "Process priority class" Ice doesn't change the priority class at all, so a priority number can be valid with a priority class but not with others.

    Glad things are working for you.
Sign In or Register to comment.