1
votes

I'm studying a course on Operating systems and I reached a part where it discusses processes and threads. I know a CPU can only run a single process at a time, so there are several scheduling algorithms out there to priorities the processes in the Ready queue.

Now when I moved to threads things started to get somewhat confusing. Since a process may consist of several threads will the scheduling be for each single thread or for each process?

For example:

I'm on Windows. I double click a song to start it in VLC then double click MS Word to start writing a report and finally open Chrome to check my mail.

Lets assume the following to simplify things:

  • VLC process has only a single thread.
  • MS Word has 5 threads in its process.
  • Chrome creates a thread for each tab I open in the browser.
  • All these programs are written in Java and all threads in these programs are created using the Thread class.

Now which of these is a User thread and which is a Kernel thread?

Will scheduling be on the processes or on the threads?

Will the processes with higher number of threads run longer or is the operating system ignorant of the number of threads in each process?

1
Thread == lightweight process. Scheduling happens at the level of threads, not processes.Marko Topolnik

1 Answers

1
votes

Applications are developed via different languages and the different languages implement threading differently. There are basically 2 different implementations.

  1. Create separate Kernel Thread for each thread created in the application.
  2. Manage the application created thread within a main thread of application.

Note : Java's implementation could also vary JVM to JVM so it depends that which JVM and OS are used.

Coming to your next question. Scheduling will be on Threads not on Processes.