Finding Out Your Processor and Operating System Configuration

Purpose: often one needs to know something about the system on which the application is running to do the right thing. Here are some ways to get info.


Here's a simple Tcl script which outputs a number of pieces of information:

 #! /usr/tcl84/bin/tclsh
 puts "This is Tcl version $tcl_version , patchlevel $tcl_patchLevel"
 puts "[info nameofexecutable] is [info tclversion] patch [info patchlevel]"
 puts "Directory(s) where package require will search:"
 puts "$auto_path"
 puts "tcl_libPath = $tcl_libPath"  ;# May want to skip this one
 puts "tcl_pkgPath = $tcl_pkgPath"  ;# May want to skip this one
 puts "tcl_library = $tcl_library"
 puts "info library = [info library]"
 puts "Shared libraries are expected to use the extension [info sharedlibextension]"
 puts "platform information:"
 parray tcl_platform

A good start is to look at what version of Tcl you've got:

 info patchlevel

Then look at the contents of the tcl_platform global array:

 parray tcl_platform

See tcl_platform for a list of the output of this command on various systems.

See info library for the location where tcl's core libraries are installed. See the variable $auto_path for a list of directories where tcl will search for extensions. See the variable $tcl_pkgPath for a list of directories where some versions of tcl seek [...] See tcl_libPath for [what??].

Now, if you are running Unix, you can obtain additional machine configuration information by running:

 exec uname -a

And for Solaris users, you can find out your processor speed using the following magic incantation:

 exec psrinfo -v

(the executable is located in /usr/sbin on this machine at least... :^)

On Linux, you can work out your basic memory usage profile using:

 exec free

Unix systems with the luxury of a SYSV ps (like both IRIX and Solaris) can use it to discover useful info about the Tcl process itself:

 exec /bin/ps -p [pid] -o {pid sz rss util pcpu time etime comm}

And there is also sysconf which is exposed on IRIX systems but not Solaris AFAICT...

 exec sysconf

Actually, solaris has sysinfo, but it's not all that useful ;^)

I am rather partial to:

   set name xterm
   exec /bin/ps -Ao fname,pid,pcpu,pmem,vsz,rss,etime | grep $name

-PSE


See Measuring your Application's CPU Utilization for a related discussion.


Please extend this page with goodies and snippets from other OSes that I know less well! DKF

For all versions of Windows, download applications from: [L1 ]

For Windows NT 4.0 and up, the TWAPI commands get_os_info, get_memory_info, get_network_info and get_processor_info will provide various types of system information.


CL maintains an exhausting, if not exhaustive, list of ways to calculate memory characteristics under various Unix flavors at [L2 ]. Several of these commands give configuration information beyond memory.


AK: Very new, and considered alpha is tcl-hwloc , a binding to Hwloc , the "Portable Hardware Locality" library.