TIP 178: [info pid] and [info tid] Subcommands

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Joe Mistachkin <joe@mistachkin.com>
State:          Draft
Type:           Project
Vote:           Pending
Created:        21-Mar-2004
Post-History:   
Tcl-Version:    8.7

Abstract

This TIP proposes two new info subcommands which are used to obtain the current process and thread identifiers.

Rationale

In certain types of applications, it is important to know what thread is currently executing. This is especially true for multithreaded applications or for scripts running in a threaded build of Tcl.

While the author realizes that there is already a pid command, the addition of the info pid subcommand still makes sense for the following reasons:

Justification

The info tid command should be in the core because the identity of the currently executing thread is just as fundamental on all modern operating systems as the current process identity. Once the thread identity is known, it can be used to communicate with other processes and threads in useful ways that do not require the Thread package. Loading the entire Thread package just to get the identity of the currently executing thread is overkill and may not be a good solution in application embedding scenarios. This is especially true for the browser plugin where loading extra packages is not ideal.

Proposed Change

Two new subcommands, info pid and info tid, would be added to the info command with the following syntax:

info pid

This subcommand would return the process identifier for the current process.

info tid

This subcommand would return the thread identifier for the current thread.

Draft Implmentation

A complete implementation of this TIP is available http://sf.net/tracker/?func=detail&aid=920731&group_id=10894&atid=310894 .

Copyright

This document has been placed in the public domain.

History