0

I'm reading OS Concepts for my undergrad OS class and came across this topic: Pthread scheduling (System and Process)

Then I kept reading and came across POSIX Real-Time Scheduling that has two scheduling classes:

SCHED_FIFO: first come first serve
SCHED_RR: round robin

Does this mean scheduling is different for real time computing or are they different levels of thread scheduling regardless of whether it is real time or not?

This is the POSIX API shown for real time scheduling:

pthread attr getschedpolicy(pthread attr t *attr, int
*policy)
pthread attr setschedpolicy(pthread attr t *attr, int policy)

Edit: I think there is a different Linux real time kernel for which these APIs are applicable: https://www.embedded.com/comparing-real-time-scheduling-on-the-linux-kernel-and-an-rtos/

Can anyone confirm this is the case?

mLstudent33
  • 101
  • 3
  • 1
    Both policies can be used for real-time programming. Whether FIFO or round robin is appropriate depends on the problem being solved. – James McLeod Dec 31 '19 at 23:58
  • so in Linux's case, process scope is unavailable so basically just set the schedule, is that correct? – mLstudent33 Jan 01 '20 at 03:47
  • it has been ages since I used Pthreads. But I think it is more correct to say that while process scope is not available directly, we can still set certain attributes for it(like RR vs FIFO). I don’t understand the question in your comment, unfortunately, and I am having trouble relating it to your main question. – James McLeod Jan 01 '20 at 03:56
  • I read the man pages and it said that only `pthread_attr_setscope(&attr,PTHREAD_SCOPE_SYSTEM);` and not `PTHREAD_SCOPE_PROCESS)` is available in Linux. So basically scope cannot be changed but the scheduling policy can? – mLstudent33 Jan 01 '20 at 04:15
  • Hypothetically, if I could change the scope, then I'm guessing that I could have different scheduling policies for each process. – mLstudent33 Jan 01 '20 at 04:16
  • Yes, Pthread scope can only be PTHREAD_SCOPE_PROCESS under Linux. But this is independent of the policy. You can still set different scheduling policies for each thread. Scope just determines which threads are competing for CPU - those in the process or all. Don’t let yourself think they are related. – James McLeod Jan 01 '20 at 05:15

0 Answers0