#include "util/u_thread.h"
#include "u_process.h"
+#if defined(__linux__)
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+#endif
+
+
/* Define 256MB */
#define S_256MB (256 * 1024 * 1024)
static void
global_init(void)
{
- LIST_INITHEAD(&queue_list);
+ list_inithead(&queue_list);
atexit(atexit_handler);
}
call_once(&atexit_once_flag, global_init);
mtx_lock(&exit_mutex);
- LIST_ADD(&queue->head, &queue_list);
+ list_add(&queue->head, &queue_list);
mtx_unlock(&exit_mutex);
}
mtx_lock(&exit_mutex);
LIST_FOR_EACH_ENTRY_SAFE(iter, tmp, &queue_list, head) {
if (iter == queue) {
- LIST_DEL(&iter->head);
+ list_del(&iter->head);
break;
}
}
}
#endif
+#if defined(__linux__)
+ if (queue->flags & UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY) {
+ /* The nice() function can only set a maximum of 19. */
+ setpriority(PRIO_PROCESS, syscall(SYS_gettid), 19);
+ }
+#endif
+
if (strlen(queue->name) > 0) {
char name[16];
snprintf(name, sizeof(name), "%s%i", queue->name, thread_index);
queue->num_queued--;
cnd_signal(&queue->has_space_cond);
+ if (job.job)
+ queue->total_jobs_size -= job.job_size;
mtx_unlock(&queue->lock);
if (job.job) {
util_queue_fence_signal(job.fence);
if (job.cleanup)
job.cleanup(job.job, thread_index);
-
- queue->total_jobs_size -= job.job_size;
}
}
}
if (queue->flags & UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY) {
-#if defined(__linux__) && defined(SCHED_IDLE)
+#if defined(__linux__) && defined(SCHED_BATCH)
struct sched_param sched_param = {0};
/* The nice() function can only set a maximum of 19.
- * SCHED_IDLE is the same as nice = 20.
+ * SCHED_BATCH gives the scheduler a hint that this is a latency
+ * insensitive thread.
*
* Note that Linux only allows decreasing the priority. The original
* priority can't be restored.
*/
- pthread_setschedparam(queue->threads[index], SCHED_IDLE, &sched_param);
+ pthread_setschedparam(queue->threads[index], SCHED_BATCH, &sched_param);
#endif
}
return true;