thread-priority

pthread_create warning on android

六眼飞鱼酱① 提交于 2019-12-05 12:23:30
After calling pthread_create function I receive next message: W/libc (26409): pthread_create sched_setscheduler call failed: Operation not permitted The code used to create the thread is: pthread_attr_t threadAttr; int ret = pthread_attr_init(&threadAttr); //code to check ret - it's 0 size_t guard_size = 0; pthread_attr_getguardsize(&threadAttr, &guard_size); ret = pthread_attr_setstacksize(&threadAttr, myStackSize + guard_size); //code to check ret - it's 0 ret = pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); //code to check ret - it's 0 ret = pthread_attr_setschedpolicy(

How to give priority to certain queries?

旧城冷巷雨未停 提交于 2019-12-05 04:36:05
On certain occasions, when several back-end process happen to run at the same time (queue management is something else, I can solve it like that, but this is not the question here), I get General error: 1205 Lock wait timeout exceeded; try restarting transaction ROLLING BACK The process which has less priority is the one that locks the table, due to the fact that it started a few minutes before the high priority one. How do I give priority to a query over an already running process? Hope it was clear enough. Once a query has begun execution it cannot be paused/interrupted. The only exception

How to deprioritize Java testrunner in Eclipse breakpoints?

这一生的挚爱 提交于 2019-12-04 05:11:33
If I am debugging some multithreaded Java code in Eclipse - with a main class RunTest, and an interesting class QueueListener. Assumptions: When RunTest is initialized - QueueListener runs in the background. When RunTest finalises - QueueListener is terminated There is a single method in RunTest - with a breakpoint in it There is a single method in QueueListener with a breakpoint in it QueueListener can run over and over again RunTest only runs once per execution (parent class) When debugging in Eclipse - both breakpoints come up. But Eclipse gives priority to RunTest - and I have to manually

Can't provoke Priority Inversion in C++

ぐ巨炮叔叔 提交于 2019-12-03 17:34:43
I'm trying to provoke Priority Inversion on a small C++ program for demonstration purposes but I can't: The low priority thread that holds the mutex is not preempted and keeps running on the critical section. This is what I'm doing: // let's declare a global mutex pthread_mutex_t my_mutex; ... int main(int argc, char **argv) { ... pthread_t normal_thread; pthread_t prio_thread; pthread_mutexattr_t attr; pthread_mutexattr_init (&attr); pthread_mutexattr_setprotocol (&attr, PTHREAD_PRIO_NONE); // ! None ! pthread_mutex_init(&my_mutex, &attr); // create first normal thread (L): pthread_create(

C linux pthread thread priority

假装没事ソ 提交于 2019-12-03 16:32:27
问题 My program has one background thread that fills and swaps the back buffer of a double buffer implementation. The main thread uses the front buffer to send out data. The problem is the main thread gets more processing time on average when I run the program. I want the opposite behavior since filling the back buffer is a more time consuming process then processing and sending out data to the client. How can I achieve this with C POSIX pthreads on Linux? 回答1: In my experience, if, in the absence

Is Java preemptive?

三世轮回 提交于 2019-12-03 13:55:11
I've seen many answers to this question but I'm still not sure. One of them was "Java is preemptive". (The JVM schedules using a preemptive, priority based scheduling algorithm (usually round robin algorithm). The second was that if 2 threads with the same priority run Java will not preempt and one thread could starve. So now I wrote a program to check it out, I created 10 threads with minimum priority followed by 10 threads with maximum priority, the results were that I jump between all of the threads - meaning Java is preemptive even if 2 threads are with the same priority /* * To change

C linux pthread thread priority

一世执手 提交于 2019-12-03 05:44:10
My program has one background thread that fills and swaps the back buffer of a double buffer implementation. The main thread uses the front buffer to send out data. The problem is the main thread gets more processing time on average when I run the program. I want the opposite behavior since filling the back buffer is a more time consuming process then processing and sending out data to the client. How can I achieve this with C POSIX pthreads on Linux? In my experience, if, in the absence of prioritisation your main thread is getting more CPU then this means one of two things: it actually needs

Thread priority does not work as expected?

好久不见. 提交于 2019-12-02 07:00:12
问题 i made a program using Thread priority and i got the same number of clicks for both thread with priority 1 and thread with priority 10 , its confusing why i am getting this class clicker implements Runnable { int click = 0; Thread t; private volatile boolean running = true; public clicker(int p) { t = new Thread(this); t.setPriority(p); } public void run() { while (running) { click++; } } public void stop() { running = false; } public void start() { t.start(); } } class hilopri { public

Thread priority does not work as expected?

心已入冬 提交于 2019-12-02 03:29:44
i made a program using Thread priority and i got the same number of clicks for both thread with priority 1 and thread with priority 10 , its confusing why i am getting this class clicker implements Runnable { int click = 0; Thread t; private volatile boolean running = true; public clicker(int p) { t = new Thread(this); t.setPriority(p); } public void run() { while (running) { click++; } } public void stop() { running = false; } public void start() { t.start(); } } class hilopri { public static void main(String args[]) { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); clicker hi = new

Testing thread priority. How come in some cases low priority threads are faster?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 23:55:22
I'm trying to test 2 threads, one with high, and the other with low priority. According to my results sometimes the low priority thread is faster, how is this possible? I've tested the different priority threads by increment a click variable inside each thread. I've also increased and decreased the sleep time, but nothing. Since I was testing with no heavy programs running in the background, I decided to test with an HD movie running, but still no real change, threads are always the same speed. My PC is an Intel i5. I'm running Windows 7 64bit, 16GB RAM This is the code: class clicker