Skip to content

Commit

Permalink
MRP-10, support for thread priorities.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Rogers committed Jun 1, 2009
1 parent f825483 commit bee0139
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions rvm/src/org/jikesrvm/runtime/BootRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void setHeapRange(int id, Address start, Address end) {
public Address sysThreadBindSupportedIP;
public Address sysThreadBindIP;
public Address sysThreadCreateIP;
public Address sysThreadSetPriorityIP;
public Address sysThreadYieldIP;
public Address sysThreadSelfIP;
public Address sysStashVMThreadIP;
Expand Down
4 changes: 4 additions & 0 deletions rvm/src/org/jikesrvm/runtime/SysCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public abstract class SysCall {
@SysCallTemplate
public abstract void sysThreadBind(int cpuId);


@SysCallTemplate
public abstract void sysThreadSetPriority(Address thread, int priority);

@SysCallTemplate
public abstract void sysThreadYield();

Expand Down
4 changes: 3 additions & 1 deletion rvm/src/org/jikesrvm/scheduler/RVMThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -4101,8 +4101,10 @@ public final int getPriority() {
* @see java.lang.Thread#getPriority()
*/
public final void setPriority(int priority) {
if (priority < 0) priority = 0;
else if (priority > 10) priority = 10;
this.priority = priority;
// @TODO this should be calling a syscall
sysCall.sysThreadSetPriority(pthread_id, priority);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tools/bootloader/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ EXTERNAL void sysThreadTerminate();
EXTERNAL int sysThreadBindSupported();
EXTERNAL void sysThreadBind(int UNUSED cpuId);
EXTERNAL Address sysThreadSelf();
EXTERNAL void sysThreadSetPriority(Address thread, int priority);
EXTERNAL void sysThreadYield();
EXTERNAL void sysNanoSleep(long long howLongNanos);
EXTERNAL Address sysMonitorCreate();
Expand Down
16 changes: 16 additions & 0 deletions tools/bootloader/sysThread.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,22 @@ EXTERNAL Address sysThreadSelf()
return (Address)thread;
}

/**
* Set priority of thread to
* @param thread [in] thread to change priority of
* @param priority [in] new priority (range of 0 to 10)
*/
EXTERNAL void sysThreadSetPriority(Address thread, int priority)
{
SYS_START();
TRACE_PRINTF("%s: sysThreadSetPriority: thread %p %d\n", Me, thread, priority);
#ifdef RVM_FOR_HARMONY
hythread_set_priority((hythread_t)thread, priority);
#else
pthread_setschedprio((pthread_t)thread, priority - 5);
#endif
}

/**
* Yield execution of current thread back to o/s.
*/
Expand Down

0 comments on commit bee0139

Please sign in to comment.