We are working on a new project on XU316-1024-FB265-C32, based on Xmos USB Audio 2 development software kit. Using Xmos Tools 15.2.1. We would like to prioritize 1 or 2 of the tasks. I tried using approach described in AN02030, but ran into a build problem with including xcore/thread.h, problem with the Assembly code in header files(s). I tried defining functions myself, it built ok, but has a runtime problem. Still not right. Any tips on setting a thread to high priority mode. (here is what I"ve tried)
#define THREAD_MODE_HIGH_PRIORITY 0x1
static inline void local_thread_mode_set_bits(unsigned bits)
{
__asm__ volatile("setpt res[%0], %1" :: "r"(0xF), "r"(bits));
}
// call from within top of thread,
local_thread_mode_set_bits(THREAD_MODE_HIGH_PRIORITY);
Task Priority Using Priority Modes
-
- Experienced Member
- Posts: 69
- Joined: Fri Mar 25, 2011 12:36 am
-
- Respected Member
- Posts: 263
- Joined: Mon Jan 08, 2018 4:14 pm
well, setting a core as high priority is done with setsr 0x400, and low priority with clrsr 0x400, not setpt
-
- Experienced Member
- Posts: 69
- Joined: Fri Mar 25, 2011 12:36 am
Is this what you mean?
__asm__ volatile("setsr 0x400");
Does this enable user level interrupts OR does it actually set the priority. Isn't the Processor Status register used to set high priority mode? Maybe I'm missing something.
__asm__ volatile("setsr 0x400");
Does this enable user level interrupts OR does it actually set the priority. Isn't the Processor Status register used to set high priority mode? Maybe I'm missing something.
-
- Respected Member
- Posts: 263
- Joined: Mon Jan 08, 2018 4:14 pm
I had recently to do a priority switch in assembly and then I found this in disassembling a program containing set_core_high_priority_on()/off
and it works.
the ISA says:
the HIPRI mask is 0x400
also you can find it in the xcore_thread_impl.h
yes this register is also used for the interrupt flag
and it works.
the ISA says:
Code: Select all
The ability of a
thread to accept events or interrupts is controlled by information held in the thread status
register (sr), and may be explicitly controlled using SETSR and CLRSR instructions with
appropriate operands.
SETSR sr ←sr ∨u16 set thread state
CLRSR sr ←sr ∧¬u16 clear thread state
GETSR r11 ←sr ∧u16 get thread state
The operand of these instructions should be one (or more) of
EEBLE enable events
IEBLE enable interrupts
INENB determine if thread is enabling events
ININT determine if thread is in interrupt mode
HIPRI set thread to high priority mode
FAST set thread to fast mode
KEDI set thread to switch to dual issue on kernel entry
also you can find it in the xcore_thread_impl.h
yes this register is also used for the interrupt flag