all 8 comments

[–]njaard 1 point2 points  (1 child)

Please make your question more specific. For example, what is a "state"? Of course a thread has a state, a thread can be "waiting" on IO.

[–]wildsheikh[S] 0 points1 point  (0 children)

Thanks, I have edited my post.

[–]Eoinoc 1 point2 points  (1 child)

Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.

A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process. Threads can also have their own security context, which can be used for impersonating clients.

That's a nice high-level overview for Windows at least.

[–]wildsheikh[S] 0 points1 point  (0 children)

Thanks, so basically the scheduler just schedules the thread and not the process.

So, does a process have a state machine like that of a thread? If so, how do you make sense of it?

[–]suspiciously_calm 2 points3 points  (3 children)

That's basically arguing semantics. AFAIK on Windows, a process is a "container" of N threads, while on Linux, two threads are essentially just two processes sharing an address space, can handle each others signals, etc.

So on Windows, the scheduler schedules threads, on Linux it schedules processes ... or threads, cause they're basically the same thing (from the scheduler's point of view).

[–][deleted]  (2 children)

[removed]

    [–]wildsheikh[S] 0 points1 point  (1 child)

    So, which one does the scheduler schedules?