Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1697 Discussions

bind a process to a specified logical processor, independent of the operating System

dellya
Beginner
809 Views
Hello, I want to know if there is any way to bind process to a specified logical processor, independent of the operating system (without using the WINAPI function setProcessAffinityMask() )?
0 Kudos
6 Replies
TimP
Honored Contributor III
809 Views
This is definitely OS dependent; linux taskset provides such functionality. In addition, certain vendors' MPI and OpenMP implementations offer such facilities.
0 Kudos
dellya
Beginner
809 Views
I have to make some tests on Intel Core 2 Duo processor.My application will be on a bootable disk running under MS-DOS. I want to know if there is any way to bind a process to a logical processor, using assembly language.
0 Kudos
jimdempseyatthecove
Honored Contributor III
809 Views

If you boot to MS-DOS then the system will run with one processor enabled(the second processor is in an idle loop or hlt state).

In order to use the second processor in MS-DOS your application will have to manage the startup and suspension of the second processor. If you are savvy enoughto write the processor initializationcode then the affinity issue will be trivial.

Your options would seem to be:

a) Learn how to do this
b) Hire someone to to this
c) Run the test under a multiprocessor aware operating system
d) give up

As for a), someone may have written about how to do this and posted this on the internet. And there may be a niche software developers kit available somewherethat will help you do this. Check out http://www.drdobbs.com/and search the archives.

If you need to hire someone to do this it won't be cheap. Your "specification" is rather open ended so you would likely be on an hourly basis verses contract basis. If you can write a complete specification then you might be able to put it out for bid on a contractual basis. However, expect that after you receive the code, written to your specification, you will find that your specification didn't cover all the requirements you realy need. So you will get hit again for change orders.

If you have deep pockets, I would consider helping you out. There are software developer sites on the internet where you can post a request for proposal. Keep in mind that almost all the software developers are application developers and only a handful have experienced coding similar to this.

Many years ago I wrote a comparably difficult developers tool which provided a 32-bit flat programming model under Real Mode DOS (BCCx32 was the name). This was advertised in DrDobbs Journal and elsewhere. Due to the niche type of market, sales never covered advertising costs. Your niche will be smaller yet, so expect to pay the full cost of development. Dont expect the developer to amortize the development costs over potential future sales.

Jim Dempsey

0 Kudos
dellya
Beginner
809 Views
I'm hired to do this. :) I don't need to test all logical processors, i have to run the tests on each of the two cores. I taught that if i find out using cpuid which logical processor corresponds to each core I can bind my application to the corresponding logical processor for each core by setting the affinity mask. I'm wondering if there is another way to run the tests on each of the two cores. Unfortunately, i din't find any documentation referring to this issue.
0 Kudos
jimdempseyatthecove
Honored Contributor III
809 Views

Affinity binding is an Operating System function.

DOS is a single processor operating system that runs in 16-bit Real Mode. It doesn't know about the other processor much less about how to select affinity for the applicaiton.

To activate the 2nd processor and/or run in 32-bit mode you will have to write what amounts to a specialized DOS extender. Depending on your BIOS you may be able to disable one or the other processors via the CMOS setup utility. You will still end up booting to DOS but you will have your choice of processors.

Next, to test the processors, I would guess you would like to test using all or parts of your installed RAM. DOS - as-is give you 16-bit Real Mode with access to the first 1MB of address space which includes 360KB of I/O address space (leaving you with 640MB of RAM for testing). To get at the other RAM you will have to write your own DOS extender.

With the 640KB and 16-bit restriction you can do a reasonable amount of testing.

Jim

0 Kudos
SHIH_K_Intel
Employee
809 Views

To do what you want, you'll need to
i) Query processor(s) configuration
ii) Ability to switch execution control from one logical processor to another.

DOS has no concept of mulitple processors, so you can't get info on i) from DOS, let alone ii).

Nevertheless, modern BIOS does collect processor configuration and construct data structures and passes these processor configuration info to OS in the form of tables according to ACPI spec (Older MP-aware OS like NT uses a different format, which is outdated now).

Secondly, if you are knowledgeable about programming interrupts, the IPI mechanism allows software to wake up another logical processor, hence providing the basis of switching execution control from one processor to another. Essentially, this is how affinity binding is implemented by MP-aware OS.

You can read up on ACPI spec to learn more of the tables that BIOS passes to OS; The basics of IPI you can find in our processor manuals, how to implement the appropriate interrupt service routine is outside the scope of processor manuals. You may also be able to gleam how Linux kernel handles the IPI that interests you.

The bottom line is, you can decide to writea real-mode OS to manage process creation/scheduling/resource-binding/context switching, or do you own extension of DOS to tack on some of these process creation/scheduling/resource-binding/context switching capabilies.

0 Kudos
Reply