
Managing Thread Priorities in Java, POSIX, and C++11
Learn how to set thread priorities in Java, manage execution with POSIX thread priorities, and work with thread priorities in C++11. Explore code examples and explanations for each method.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
SE3910 REAL TIME SYSTEMS Thread Priorities Slide Style & Content: Dr. Schilling More Content: Dr. Yoder
Explain how to set thread priority in Java. Construct code which sets thread priority in Java. Explain how to set the thread priorities in POSIX Construct code which uses POSIX thread priorities to manage execution OBJECTIVES Explain how one sets thread priorities using C++11 threads. SE3910 REAL TIME SYSTEMS
Java java.lang.Thread No external jar needed Thread t = new Thread(r) t.start(); interface Runnable { void run(); } t.join(); Object o; synchronized(o) { } /* Garbage coll. */ Pthreads #include <pthread.h> link with -pthread pthread_create(t,r,sr,a) THREADING PTHREADS Parameter: void* (*sr) (void *) pthread_join(*t, &p) pthread_mutex_init(m,null) pthread_mutex_lock( ) pthread_mutex_destroy( ) (REVIEW) 3
Java Object o; o.notify(); o.wait(); o.notify(); o.notifyAll(); pthreads phread_cond_t c = PTHREAD_COND_INITIALIZER; pthread_cond_broadcast(c); pthread_cond_wait(c,m); phtread_cond_signal(c); phtread_cond_broadcast(c); THREADING PTHREADS (UPDATED) SE-3910 - DR. JOSIAH YODER SLIDE STYLE: DR. HORNICK MUCH MATERIAL: DR. SCHILLING 4
Java java.lang.Thread No external jar needed Thread t = new Thread(r) t.start(); interface Runnable { void run(); } t.join(); qthreads #include <QThread> THREADING QTHREADS (qmake, moc and friends take care of this) QThread *q = new QThread; moveToThread(o); QObject (e.g. QWidget (e.g. QMainWindow)) connect the QThread::finish() signal to a slot that checks if all threads are done. QMutex Avoid sharing memory entirely Object o; synchronized(o) { } /* Garbage coll. */ ???? 5
INTO QT SLOTS/SIGNALS == A QThread should be used much like a regular thread instance: prepare an object (QObject) class with all your desired functionality in it. Then create a new QThread instance, push the QObject onto it using moveToThread(QThread*) of the QObject instance and call start() on the QThread instance. That s all. EVENTS https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly- use-qthreads-the-full-explanation/ I have used this approach this is what the example QtPrimeApp (or something like that) does SE-2811 DR.YODER 6
C++11 THREADS http://indico.cern.ch/event/199138/session/6/contribution/20/material/paper/0.pdf SE3910 REAL TIME SYSTEMS
C++11 THREADS SE3910 REAL TIME SYSTEMS
THE INTEGRATION THREAD SE3910 REAL TIME SYSTEMS
RESULTS SE3910 REAL TIME SYSTEMS
How do you set the thread priority in Java? JAVA THREADS SE3910 REAL TIME SYSTEMS
PTHREADS PRIORITY SCHEDULING SE3910 REAL TIME SYSTEMS
PTHREAD AFFINITY SE3910 REAL TIME SYSTEMS
PTHREAD PRIORITY QUEUES SE3910 REAL TIME SYSTEMS
SCHEDULING POLICY SE3910 REAL TIME SYSTEMS
SCHEDULER SE3910 REAL TIME SYSTEMS
SETTING ATTRIBUTES SE3910 REAL TIME SYSTEMS
PTHREAD INHERITANCE SE3910 REAL TIME SYSTEMS
EXAMPLE SE3910 REAL TIME SYSTEMS