Ticket #1659: thread_priority_setting.diff

File thread_priority_setting.diff, 3.4 KB (added by Janne <janne-mythtv@…>, 14 years ago)
  • libs/libmythtv/eitscanner.cpp

    old new  
    11// -*- Mode: c++ -*-
    22
     3// POSIX headers
     4#include <sys/time.h>
     5#include <sys/resource.h>
     6
    37#include "tv_rec.h"
    48
    59#include "channelbase.h"
    EITScanner::EITScanner() 
    3034    eitHelper->SetLanguagePreferences(langPref);
    3135
    3236    pthread_create(&eventThread, NULL, SpawnEventLoop, this);
    33 
    34     // Lower scheduling priority, to avoid problems with recordings.
    35     struct sched_param sp = {19 /* very low priority */};
    36     pthread_setschedparam(eventThread, SCHED_OTHER, &sp);
    3737}
    3838
    3939void EITScanner::TeardownAll(void)
    void EITScanner::TeardownAll(void) 
    5959 */
    6060void *EITScanner::SpawnEventLoop(void *param)
    6161{
     62    // Lower scheduling priority, to avoid problems with recordings.
     63    if (setpriority(PRIO_PROCESS, 0, 19))
     64        VERBOSE(VB_IMPORTANT, LOC + "Setting priority failed." + ENO);
    6265    EITScanner *scanner = (EITScanner*) param;
    6366    scanner->RunEventLoop();
    6467    return NULL;
  • libs/libmythtv/previewgenerator.cpp

    old new  
    55#include <sys/types.h> // for stat
    66#include <sys/stat.h>  // for stat
    77#include <unistd.h>    // for stat
     8#include <sys/time.h>
     9#include <sys/resource.h>
    810
    911// Qt headers
    1012#include <qfileinfo.h>
    void PreviewGenerator::disconnectSafe(vo 
    156158void PreviewGenerator::Start(void)
    157159{
    158160    pthread_create(&previewThread, NULL, PreviewRun, this);
    159     // Lower scheduling priority, to avoid problems with recordings.
    160     struct sched_param sp = {9 /* lower than normal */};
    161     pthread_setschedparam(previewThread, SCHED_OTHER, &sp);
    162161    // detach, so we don't have to join thread to free thread local mem.
    163162    pthread_detach(previewThread);
    164163}
    void PreviewGenerator::Run(void) 
    185184
    186185void *PreviewGenerator::PreviewRun(void *param)
    187186{
     187    // Lower scheduling priority, to avoid problems with recordings.
     188    if (setpriority(PRIO_PROCESS, 0, 9))
     189        VERBOSE(VB_IMPORTANT, LOC + "Setting priority failed." + ENO);
    188190    PreviewGenerator *gen = (PreviewGenerator*) param;
    189191    gen->createSockets = true;
    190192    gen->Run();
  • programs/mythbackend/scheduler.cpp

    old new Scheduler::Scheduler(bool runthread, QMa 
    7171    {
    7272        pthread_t scthread;
    7373        pthread_create(&scthread, NULL, SchedulerThread, this);
    74 
    75         // Lower scheduling priority, to avoid problems with recordings.
    76         struct sched_param sp = {9 /* lower than normal */};
    77         pthread_setschedparam(scthread, SCHED_OTHER, &sp);
    7874    }
    7975}
    8076
    void Scheduler::ShutdownServer(int prero 
    15921588
    15931589void *Scheduler::SchedulerThread(void *param)
    15941590{
     1591    // Lower scheduling priority, to avoid problems with recordings.
     1592    if (setpriority(PRIO_PROCESS, 0, 9))
     1593        VERBOSE(VB_IMPORTANT, LOC + "Setting priority failed." + ENO);
    15951594    Scheduler *sched = (Scheduler *)param;
    15961595    sched->RunScheduler();
    15971596