java 实时优先级高于应有的
java real-time priorities is higher than it should be
*** warning: Java real-time priorities >=11 not usable, using priority 10 (cause: Operation not permitted)
目前正在尝试出现此错误消息的项目。
在 Vmware、eclipse ide 和 jamaica vm
中使用 Xfce 环境
这到底有什么问题?系统优先级为10时出现java实时优先级大于11的错误,如何设置更高的优先级?
我的代码
package realtime;
import javax.realtime.*;
class seconds extends RealtimeThread{
int secs = 0;
int mins = 0;
int hours=0;
public seconds(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
secs++;
System.out.println("seconds" + secs);
if(secs>58) {
mins ++;
secs = 0;
}
boolean ok = waitForNextPeriod();
}
}
}
class minutes extends RealtimeThread{
private minutes min = null;
private seconds sec = null;
int mins = 0;
int hours = 0;
public minutes(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
mins++;
System.out.println("minutes" + mins);
if(mins>58) {
hours ++;
mins = 0;
}
boolean ok = waitForNextPeriod();
}
}
}
class hours extends RealtimeThread{
private minutes min = null;
private seconds sec = null;
private hours hour=null;
int mins = 0;
int hours = 0;
int day =0;
public hours(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
mins++;
System.out.println("hours" + hours);
if(hours>24) {
day ++;
hours= 0;
}
boolean ok = waitForNextPeriod();
}
}
}
public class Q1 {
private minutes min = null;
private seconds sec = null;
private hours hour = null;
Q1(){
PriorityParameters hoursched = new PriorityParameters(PriorityScheduler.instance().getMaxPriority());
ReleaseParameters hoursrel = new PeriodicParameters(new RelativeTime(59*59*1000,1000));
PriorityParameters minsched = new PriorityParameters(PriorityScheduler.instance().getMinPriority());
ReleaseParameters minrel = new PeriodicParameters(new RelativeTime(59000,1000));
PriorityParameters secsched = new PriorityParameters(PriorityScheduler.instance().getMaxPriority());
ReleaseParameters secrel = new PeriodicParameters(new RelativeTime(1000,0));
hour = new hours(hoursched,hoursrel);
min = new minutes(minsched, minrel);
sec = new seconds(secsched, secrel);
hour.start();
min.start();
sec.start();
}
public static void main(String[] args) {
Q1 t = new Q1();
}
}
这是 JamaicaVM 手册中的常见问题解答:
答案是:
"The creation of a thread with real-time priority was not permitted by the operating system. Instead JamaicaVM created a thread with normal priority. This means that real-time scheduling is not available, and that the application will likely not work properly.
On off-the-shelf Linux systems, use of real-time priorities requires super-user privileges. That is, starting the application with
sudo
will resolve the issue. Alternatively, the priority limits for particular users or groups may be changed by editing /etc/security/limits.conf
and setting rtprio
to the maximum native priority used. For the default priority map used by JamaicaVM on Linux, setting the rtprio
limit to 80
is sufficient."
*** warning: Java real-time priorities >=11 not usable, using priority 10 (cause: Operation not permitted)
目前正在尝试出现此错误消息的项目。
在 Vmware、eclipse ide 和 jamaica vm
中使用 Xfce 环境这到底有什么问题?系统优先级为10时出现java实时优先级大于11的错误,如何设置更高的优先级?
我的代码
package realtime;
import javax.realtime.*;
class seconds extends RealtimeThread{
int secs = 0;
int mins = 0;
int hours=0;
public seconds(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
secs++;
System.out.println("seconds" + secs);
if(secs>58) {
mins ++;
secs = 0;
}
boolean ok = waitForNextPeriod();
}
}
}
class minutes extends RealtimeThread{
private minutes min = null;
private seconds sec = null;
int mins = 0;
int hours = 0;
public minutes(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
mins++;
System.out.println("minutes" + mins);
if(mins>58) {
hours ++;
mins = 0;
}
boolean ok = waitForNextPeriod();
}
}
}
class hours extends RealtimeThread{
private minutes min = null;
private seconds sec = null;
private hours hour=null;
int mins = 0;
int hours = 0;
int day =0;
public hours(SchedulingParameters sched, ReleaseParameters rel)
{
super(sched,rel);
}
public void run() {
while(true) {
mins++;
System.out.println("hours" + hours);
if(hours>24) {
day ++;
hours= 0;
}
boolean ok = waitForNextPeriod();
}
}
}
public class Q1 {
private minutes min = null;
private seconds sec = null;
private hours hour = null;
Q1(){
PriorityParameters hoursched = new PriorityParameters(PriorityScheduler.instance().getMaxPriority());
ReleaseParameters hoursrel = new PeriodicParameters(new RelativeTime(59*59*1000,1000));
PriorityParameters minsched = new PriorityParameters(PriorityScheduler.instance().getMinPriority());
ReleaseParameters minrel = new PeriodicParameters(new RelativeTime(59000,1000));
PriorityParameters secsched = new PriorityParameters(PriorityScheduler.instance().getMaxPriority());
ReleaseParameters secrel = new PeriodicParameters(new RelativeTime(1000,0));
hour = new hours(hoursched,hoursrel);
min = new minutes(minsched, minrel);
sec = new seconds(secsched, secrel);
hour.start();
min.start();
sec.start();
}
public static void main(String[] args) {
Q1 t = new Q1();
}
}
这是 JamaicaVM 手册中的常见问题解答:
答案是:
"The creation of a thread with real-time priority was not permitted by the operating system. Instead JamaicaVM created a thread with normal priority. This means that real-time scheduling is not available, and that the application will likely not work properly.
On off-the-shelf Linux systems, use of real-time priorities requires super-user privileges. That is, starting the application with
sudo
will resolve the issue. Alternatively, the priority limits for particular users or groups may be changed by editing/etc/security/limits.conf
and settingrtprio
to the maximum native priority used. For the default priority map used by JamaicaVM on Linux, setting thertprio
limit to80
is sufficient."