Assigning 1 CPU to do 1 Thread












0















I am implementing a code that create a pulse output via a digital IO for stepper driver.
However i notice when there is a 'stray' program running (ie anti virus), the output(duty cycle) will become inconsistent.
Is there anyway to assign that thread to 1 single CPU in multi-core CPUs so that other programs even windows managed cannot assign thread to that CPU?
I am using C# as programming.










share|improve this question


















  • 1





    Which OS are you running?

    – harogaston
    Jan 22 at 2:01











  • I am using win10 64 bits x64 Processor

    – ishtarsg
    Jan 22 at 2:32











  • I am honest to say you will be more successful if you turned to Linux.

    – harogaston
    Jan 22 at 3:18











  • @harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

    – Bob
    Jan 22 at 9:00













  • @Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

    – harogaston
    Jan 22 at 20:05


















0















I am implementing a code that create a pulse output via a digital IO for stepper driver.
However i notice when there is a 'stray' program running (ie anti virus), the output(duty cycle) will become inconsistent.
Is there anyway to assign that thread to 1 single CPU in multi-core CPUs so that other programs even windows managed cannot assign thread to that CPU?
I am using C# as programming.










share|improve this question


















  • 1





    Which OS are you running?

    – harogaston
    Jan 22 at 2:01











  • I am using win10 64 bits x64 Processor

    – ishtarsg
    Jan 22 at 2:32











  • I am honest to say you will be more successful if you turned to Linux.

    – harogaston
    Jan 22 at 3:18











  • @harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

    – Bob
    Jan 22 at 9:00













  • @Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

    – harogaston
    Jan 22 at 20:05
















0












0








0








I am implementing a code that create a pulse output via a digital IO for stepper driver.
However i notice when there is a 'stray' program running (ie anti virus), the output(duty cycle) will become inconsistent.
Is there anyway to assign that thread to 1 single CPU in multi-core CPUs so that other programs even windows managed cannot assign thread to that CPU?
I am using C# as programming.










share|improve this question














I am implementing a code that create a pulse output via a digital IO for stepper driver.
However i notice when there is a 'stray' program running (ie anti virus), the output(duty cycle) will become inconsistent.
Is there anyway to assign that thread to 1 single CPU in multi-core CPUs so that other programs even windows managed cannot assign thread to that CPU?
I am using C# as programming.







cpu threading






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 22 at 1:35









ishtarsgishtarsg

1




1








  • 1





    Which OS are you running?

    – harogaston
    Jan 22 at 2:01











  • I am using win10 64 bits x64 Processor

    – ishtarsg
    Jan 22 at 2:32











  • I am honest to say you will be more successful if you turned to Linux.

    – harogaston
    Jan 22 at 3:18











  • @harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

    – Bob
    Jan 22 at 9:00













  • @Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

    – harogaston
    Jan 22 at 20:05
















  • 1





    Which OS are you running?

    – harogaston
    Jan 22 at 2:01











  • I am using win10 64 bits x64 Processor

    – ishtarsg
    Jan 22 at 2:32











  • I am honest to say you will be more successful if you turned to Linux.

    – harogaston
    Jan 22 at 3:18











  • @harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

    – Bob
    Jan 22 at 9:00













  • @Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

    – harogaston
    Jan 22 at 20:05










1




1





Which OS are you running?

– harogaston
Jan 22 at 2:01





Which OS are you running?

– harogaston
Jan 22 at 2:01













I am using win10 64 bits x64 Processor

– ishtarsg
Jan 22 at 2:32





I am using win10 64 bits x64 Processor

– ishtarsg
Jan 22 at 2:32













I am honest to say you will be more successful if you turned to Linux.

– harogaston
Jan 22 at 3:18





I am honest to say you will be more successful if you turned to Linux.

– harogaston
Jan 22 at 3:18













@harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

– Bob
Jan 22 at 9:00







@harogaston Linux is similarly not suitable for this kind of task. You'd need either a proper RTOS or just the raw program without any OS if you want any kind of guarantee.

– Bob
Jan 22 at 9:00















@Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

– harogaston
Jan 22 at 20:05







@Bob I strongly disagree. Linux is WAY more suitable for this kind of thing than Windows. Go tell Windows how to assign CPU priority for interrupts, or for user land processes. Good luck with that! This does not mean that a real time OS is better, of course it is, for instance RT Linux. But there is no discussion that if you plan on tinkering with the kernel then you will feel way more at home on Linux.

– harogaston
Jan 22 at 20:05












1 Answer
1






active

oldest

votes


















3














The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.



A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)



However, interrupt handlers and DPC routines will still be able to interfere with your thread.



Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.



I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.



What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.






share|improve this answer





















  • 1





    Can you make the sound card or serial port somehow generate the duty cycle?

    – LawrenceC
    Jan 26 at 4:20











  • Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

    – Jamie Hanrahan
    Jan 26 at 8:37











  • The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

    – ishtarsg
    Feb 12 at 6:55











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396835%2fassigning-1-cpu-to-do-1-thread%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.



A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)



However, interrupt handlers and DPC routines will still be able to interfere with your thread.



Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.



I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.



What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.






share|improve this answer





















  • 1





    Can you make the sound card or serial port somehow generate the duty cycle?

    – LawrenceC
    Jan 26 at 4:20











  • Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

    – Jamie Hanrahan
    Jan 26 at 8:37











  • The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

    – ishtarsg
    Feb 12 at 6:55
















3














The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.



A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)



However, interrupt handlers and DPC routines will still be able to interfere with your thread.



Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.



I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.



What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.






share|improve this answer





















  • 1





    Can you make the sound card or serial port somehow generate the duty cycle?

    – LawrenceC
    Jan 26 at 4:20











  • Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

    – Jamie Hanrahan
    Jan 26 at 8:37











  • The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

    – ishtarsg
    Feb 12 at 6:55














3












3








3







The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.



A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)



However, interrupt handlers and DPC routines will still be able to interfere with your thread.



Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.



I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.



What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.






share|improve this answer















The only way to do this would be to enumerate every other process in the system and set its affinity mask to exclude the CPU you're trying to save for your thread. You'll have to keep doing this, too, as additional processes may be created at any time.



A better approach is to simply run your process in the "real time" priority class and then set your thread priority to "time critical". (I hope it doesn't have to be actually executing at too high a percentage of the total time.)



However, interrupt handlers and DPC routines will still be able to interfere with your thread.



Your real problem here is that Windows is not intended for nor suited for tasks with "hard" real-time requirements, and yours sounds like that.



I suggest using a microcontroller that's dedicated to generating the variable-duty-cycle pulses your stepper motor needs.



What is the range of frequency and duty cycle the stepper motor needs? There may be another way to solve your problem.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 26 at 2:42

























answered Jan 22 at 3:36









Jamie HanrahanJamie Hanrahan

18.8k34280




18.8k34280








  • 1





    Can you make the sound card or serial port somehow generate the duty cycle?

    – LawrenceC
    Jan 26 at 4:20











  • Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

    – Jamie Hanrahan
    Jan 26 at 8:37











  • The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

    – ishtarsg
    Feb 12 at 6:55














  • 1





    Can you make the sound card or serial port somehow generate the duty cycle?

    – LawrenceC
    Jan 26 at 4:20











  • Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

    – Jamie Hanrahan
    Jan 26 at 8:37











  • The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

    – ishtarsg
    Feb 12 at 6:55








1




1





Can you make the sound card or serial port somehow generate the duty cycle?

– LawrenceC
Jan 26 at 4:20





Can you make the sound card or serial port somehow generate the duty cycle?

– LawrenceC
Jan 26 at 4:20













Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

– Jamie Hanrahan
Jan 26 at 8:37





Yep, I was thinking about the sound card. Generate wav data of square waves with the duty cycle you need (a trivial calculation) and call WaveOut.

– Jamie Hanrahan
Jan 26 at 8:37













The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

– ishtarsg
Feb 12 at 6:55





The minimum for the driver is 400Pulse/Rev which i need for constant speed and position accuracy. Also i am using a Single board computer so sound card is kinda out for me.

– ishtarsg
Feb 12 at 6:55


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396835%2fassigning-1-cpu-to-do-1-thread%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Сан-Квентин

Алькесар

Josef Freinademetz