Find the answer to your Linux question:
Results 1 to 6 of 6
It there a way in linux to force atomicity of user code sections on a multi-core x86 chip? I know in classes I have taken we disable/enable interrupts, but I ...
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    28

    forcing atomicity in user code (C++)

    It there a way in linux to force atomicity of user code sections on a multi-core x86 chip?

    I know in classes I have taken we disable/enable interrupts, but I don't think that works on a CMP.

    Basically, I want to stop the kernel from being able to switch off my process for some period of time.

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by blah32 View Post
    It there a way in linux to force atomicity of user code sections on a multi-core x86 chip?

    ...

    Basically, I want to stop the kernel from being able to switch off my process for some period of time.
    Why are you wanting to do this? There are various ways you can "ask" Linux to give you a higher priority, more CPU time, less chance of being swapped out and such, but it depends on how much of a guarantee you need about this.

    If you want to 100% guarantee your process will get CPU time whenever it wants, you'd need to compile a real-time kernel. Just making the kernel is a lot of work, and programming real-time systems is a large and complex topic, and the odds are you don't need to be completely sure about how much CPU time you get.

    For slightly weaker assertions, see the sched_setscheduler(2) man page. You'll want to read it ALL.

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    28
    Quote Originally Posted by JohnGraham View Post
    Why are you wanting to do this? There are various ways you can "ask" Linux to give you a higher priority, more CPU time, less chance of being swapped out and such, but it depends on how much of a guarantee you need about this.

    If you want to 100% guarantee your process will get CPU time whenever it wants, you'd need to compile a real-time kernel. Just making the kernel is a lot of work, and programming real-time systems is a large and complex topic, and the odds are you don't need to be completely sure about how much CPU time you get.

    For slightly weaker assertions, see the sched_setscheduler(2) man page. You'll want to read it ALL.
    I do need a 100% assertion. I am building a real-time simulator for a research project. Is this real-time kernel already available, or does it require hacking the linux kernel?

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    i think RHEL/centos might have a RT kernel package you can readily install, otherwise you may have to build your own kernel (not very hard)

    i would just do some googling for distros with RT kernel options

  5. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    28
    Quote Originally Posted by coopstah13 View Post
    i think RHEL/centos might have a RT kernel package you can readily install, otherwise you may have to build your own kernel (not very hard)

    i would just do some googling for distros with RT kernel options
    Ok, so I looked this up and installed the rpm on fedora 13.

    My question is does this really guarantee a process can't be swapped out? How do I take advantage of that?

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Unfortunately, even so-called RT Linux is not truly deterministic. I would advise that you invest in a good commercial real-time operating system that can easily do what you need, yet communicate easily with a Linux front-end. One good one is QNX - they have free or low-cost licenses for academic and personal use. Go to QNX Realtime Operating System (RTOS) software, middleware, development tools and services for superior embedded design for more information.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...