in reply to Re^6: OT How fast a cpu to overwhelm Time::HiRes
in thread OT How fast a cpu to overwhelm Time::HiRes
Hmm, how do you measure context switches between threads?
I use the system performance monitoring tool, perfmon. I would assume that the context switches logged by sar should reflect the thread switches also.
This is done in the perl process internally, so the OS doesn't know anything about them, or am I missing something?
No. Perl never does it's own context switching. Unlike say Java, which has User-mode thread, and runs it's own mini-scheduler internally to the process. Perl uses Kernel-mode threads, which are scheduled (naturally enough) by the kernel.
With User-mode threads, all the threads of a single process share the timeslots allocated to the process by the OS. With Kernel-mode threads, each thread is a distinct OS-schedulable unit and get a full OS timeslice each time.
The code I posted should run on a multi-threaded Perl under linux, except you would have to change Win32::Sleep 0; for yield;. There is no point in my running your code as fork() does not create real processes under win32, it spawns threads.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: OT How fast a cpu to overwhelm Time::HiRes
by tirwhan (Abbot) on Dec 01, 2005 at 14:23 UTC | |
by BrowserUk (Patriarch) on Dec 01, 2005 at 15:00 UTC | |
by tirwhan (Abbot) on Dec 01, 2005 at 15:45 UTC |