Opened 8 years ago

Closed 7 years ago

#10788 closed Bugs (fixed)

GetLogicalProcessor isn't available for Windows platform less or equals to 0x0502

Reported by: steve.tousignant@… Owned by: viboes
Milestone: Boost 1.60.0 Component: thread
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc:

Description

I've runned into an issue while using boost 1.56.0 and boost 1.57.0 while ours software was deployed on a Windows XP SP2. When using the threading library from boost, we have found out that it was using a feature only available on Windows XP SP3 and higher.

The effect are that the software built with Boost 1.56.0 and boost 1.57.0 refuse to start even after we force the feature set of windows XP to be used by the Windows Platform SDK.

I will attach a patch as a proposed fix for future version of boost.

Attachments (1)

boost-1.57.0-WinXP-SP2-PhysicalConcurrency-Return0.patch (767 bytes ) - added by steve.tousignant@… 8 years ago.
Proposed patch for boost threading

Download all attachments as: .zip

Change History (9)

by steve.tousignant@…, 8 years ago

Proposed patch for boost threading

comment:1 by viboes, 7 years ago

Component: threadsthread

Please, don't use the threads component but the thread one.

Last edited 7 years ago by viboes (previous) (diff)

comment:2 by viboes, 7 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

The current code is

    unsigned thread::physical_concurrency() BOOST_NOEXCEPT
    {
#if BOOST_PLAT_WINDOWS_RUNTIME || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
        return hardware_concurrency();
#else
        unsigned cores = 0;
        DWORD size = 0;

        GetLogicalProcessorInformation(NULL, &size);
        if (ERROR_INSUFFICIENT_BUFFER != GetLastError())
            return 0;

        std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> buffer(size);
        if (GetLogicalProcessorInformation(&buffer.front(), &size) == FALSE)
            return 0;

        const size_t Elements = size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);

        for (size_t i = 0; i < Elements; ++i) {
            if (buffer[i].Relationship == RelationProcessorCore)
                ++cores;
        }
        return cores;
#endif
    }

Does it works for you?

comment:3 by viboes, 7 years ago

PING !!!

comment:4 by viboes, 7 years ago

Type: BugsSupport Requests

comment:5 by viboes, 7 years ago

Type: Support RequestsBugs

comment:6 by viboes, 7 years ago

Milestone: To Be DeterminedBoost 1.60.0

#11683 describes the history of this function and how we rolled back a fix.

I've update the develop branch.

https://github.com/boostorg/thread/commit/9a8759a3dda2c63342d55d5e97ed906826cee981

comment:7 by Daniel, 7 years ago

Please also take into account the issue with comments after preprocessor continuation for VS2010 (comment:6:ticket:10824): commit/8e1be55c6d560c44fb07cc497a3480527957576c

comment:8 by viboes, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.