Thread: How was the cpu scheduling of the process implemented?

  1. #1
    Registered User
    Join Date
    Mar 2022
    Posts
    4

    How was the cpu scheduling of the process implemented?

    Hello
    I'd like to ask you about a library that implements CPU scheduling.


    1. While studying scheduling-related system calls, I have a question.
    1-1. I was wondering if developers put a system call in charge of CPU scheduling directly into the program file.
    1-2. Or when compiler C compiles the program file, I was wondering if compiler would add a separate system call in charge of CPU scheduling.
    1-3. The scheduling system call was implemented in the C library, so I couldn't see the scheduling system call with my eyes, but I was wondering if it was running.


    Meanwhile, I got a hint from an internet document.
    Scheduler-Related System Calls | The Linux Process Scheduler | InformIT


    It said that the system call related to the scheduler will be implemented in Library C.


    So when I looked at the library,
    There were a lot of header files in one header file.
    There were a lot of header files in those many header files.


    Which library or header file implemented CPU scheduling?
    Does the stdio.h file depend on the library, too?
    When the compiler compiles the program source code, does it link the scheduling-related source code?


    Thank you for reading it.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I'm guessing this is the article you refer to.
    Scheduler-Related System Calls | The Linux Process Scheduler | InformIT

    Clone the git if you want to search for things like nice()
    sourceware.org Git - glibc.git/summary

    1-1. I was wondering if developers put a system call in charge of CPU scheduling directly into the program file.
    Yes.

    1-2. Or when compiler C compiles the program file, I was wondering if compiler would add a separate system call in charge of CPU scheduling.
    No.

    1-3. The scheduling system call was implemented in the C library, so I couldn't see the scheduling system call with my eyes, but I was wondering if it was running.
    If you want to see what your program does at the user-space to kernel-space interface, then strace is your friend.
    strace(1) - Linux manual page
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2022
    Posts
    4

    Thank you for your answer. I'd like to ask a question about this answer.

    Thank you for your answer.
    I'd like to ask a question about this answer.

    1-1. I was wondering if developers put a system call in charge of CPU scheduling directly into the program file.
    Yes.


    If developers do not write a scheduling-related system call code in a program file, does the program's process not have CPU scheduling?
    Last edited by JangDongyul; 03-08-2022 at 05:15 AM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Of course it has scheduling.

    It runs under the default scheduling of whatever OS it's running on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2022
    Posts
    4
    Thank you for answering.

    Let me ask you one more question.

    If there's a program file like EXCEL,

    When developers develop EXCEL, they put the scheduling algorithm source code in the EXCEL source code, right?

    And the program file without the scheduling algorithm source code,
    You're saying that you're following the basic scheduling of the OS that's running, right?

    If so, in the case of a process that does not have a scheduling algorithm source code in itself,

    Is there a separate process in the OS to manage the scheduling of such a process?

    What's the name of the process?

    Thank you for reading it.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    The scheduler is in the kernel.

    It's not duplicated in every single compiled program.

    > Is there a separate process in the OS to manage the scheduling of such a process?
    Sure,
    linux/kernel/sched at master * torvalds/linux * GitHub

    It's a long way down to the bottom of this rabbit hole.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2022
    Posts
    4

    Professor, let me ask you one more question.

    Professor, let me ask you one more question.

    Thank you for teaching me that the CPU scheduler was a process, not a program source code in the kernel.

    I've learned that CPU scheduler is not a separate process at school.

    Until now, I learned that CPU scheduler is a passive program source code in the kernel.

    And I learned that each process is frequently caught in an interrupt, enters kernel mode, and executes CPU scheduler code in the kernel on its own at school.

    I have a question here.

    Even if user processes are frequently interrupted and enter kernel mode due to hardware signals,

    I didn't write the source code for the user process to execute the CPU scheduler source code in the kernel.

    By the way, how do processes execute the source code of the CPU scheduler in the kernel?

    That's why I asked this question.

    I knew the CPU scheduler was built into the kernel, but it wasn't a passive source code, it was a separate process.

    At school, I learned that CPU scheduler is not a separate process, but a source code built into the kernel.

    Thank you for teaching me that the CPU scheduler was a process, not a program source code in the kernel.


    Then, When entering PS-ef instructions into the shell,

    what are the PID and CMD of the CPU scheduler process?
    Last edited by JangDongyul; 03-09-2022 at 03:08 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How is tolower() implemented if..
    By Nwb in forum C Programming
    Replies: 5
    Last Post: 10-10-2020, 06:16 AM
  2. Could this be implemented a simpler way?
    By TropicalStarfis in forum C Programming
    Replies: 6
    Last Post: 08-06-2012, 08:16 AM
  3. process scheduling
    By lordofdarkness in forum C Programming
    Replies: 0
    Last Post: 03-29-2010, 04:53 PM
  4. Process Scheduling using fork()
    By mannyginda2g in forum C++ Programming
    Replies: 8
    Last Post: 03-08-2005, 05:09 PM
  5. What is a Map/Table? How is it Implemented?
    By Artist_of_dream in forum C++ Programming
    Replies: 4
    Last Post: 02-13-2005, 03:42 PM

Tags for this Thread