Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:57:26+00:00 2026-05-25T01:57:26+00:00

I am trying to build simple and small preemptive OS for the ARM processor

  • 0

I am trying to build simple and small preemptive OS for the ARM processor (for experimenting with the ARM architecture).

I have my TCB that have pointer to the proper thread’s stack which I am updating/reading from in my dispatch() method – something like this (mixed C and assembly)

asm("
  ldr r5, =oldSP
  ldr sp, [r5]
");
myThread->sp = oldSP;
myThread = getNewThread();
newSP = myThread->sp
asm("
  ldr r5, =newSP
  str sp, [r5]
");

When I call this dispatch() from user mode (explicit call), everything works all right – threads are losing and getting processor as they should.

However, I am trying to build preemptive OS, so I need timer IRQ to call dispatch – and that is my problem – in irq mode, r13_usr register is hidden, so I can’t access it. I can’t change to the SVC mode either – it is hidden there, too.

One solution that I see is switching to the user mode (after I entered dispatch method), updating/changing sp fields and switching back to the irq mode to continue where I left. Is that possible?

Another solution is to try not to enter IRQ mode again – I just need to handle hardware things (set proper status bit in timer periphery), call dispatch() (still in irq mode) in which I will mask timer interrupt, change to the user mode, do context switch, unmask timer interrupt and continue. Resumed thread should continue where it was suspended (before entering IRQ). Is this correct? (This should be correct if on interrupt, processor pushes r4-r11 and lr into user stack, but I think I am wrong here…)

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:57:27+00:00Added an answer on May 25, 2026 at 1:57 am

    I think I might have answered a similar question here: “ARM – access R13 and R14 from Supervisor Mode”

    In your case, just use “IRQ mode” instead of “Supervisor mode”, but I think the same principle applies.

    Long & short of it, if you switch from IRQ to user mode, that’s a one-way trap door, you can’t simply switch back to IRQ mode under software control.

    But by manipulating the CPSR and switching to system mode, you can get r13_usr and then switch back to the previous mode (in your case, IRQ mode).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple Magento Module that needs to connect to the
I'm trying to build a simple jquery plugin that can take selectors as parameters.
I'm trying to build a simple echo server/client that works on ethernet level(using raw
Im trying to build a simple AJAX script that uses a form to send
I'm trying to build a simple component extending spark.components.Group to have a background color,
I get the following errors when trying to build a small and simple project
What I'm trying to do: build a super simple button skin (say a small
I'm trying to build a simple parser, and since InputStream doesn't have some peek-like
I'm trying to build a simple User Template system so that my users can
I'm trying to build a simple environment check script for my firm's test environment.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.