locate_task

Gamma: Version 4.0
Prev |  | Next

# `locate_task`

`locate_task` -- finds and connects to tasks by name.

## Syntax

    locate_task (task_name, async_reqd)

## Arguments

`task_name`

  The name of the task to locate. The other task must have declared this name through `init_ipc` or `name_attach`.

`async_reqd`

  t if `locate_task` should automatically call `init_async_ipc` for this task.

## Returns

A task if successful, otherwise nil.

## Description

This function makes a call to the name locator task for the current operating system. If it finds the named task it makes an IPC connection (in TCP/IP) or creates a virtual circuit (in QNX 4) to that task. If `async_reqd` is t, then `init_async_ipc` is also called.

| When Gamma locates a task, it returns a printed representation of it, which looks like this: #<Task:10120>. This representation cannot be read back into Gamma, so a symbol is usually assigned when calling `locate_task` to facilitate refering to or working with a task. We refer to this symbol as the task descriptor. For instance, in the example below, the symbol `tsk` is the task descriptor.

## Example

| The two tasks are initiated with `init_ipc` before calling `locate_task`.

Task 1:

        Gamma> init_ipc("first","Q1");
        t
        Gamma> getpid();
        9231
        Gamma> tsk = locate_task("second",nil);
        #<Task:9092>
        Gamma> send (tsk, #princ("Are you there?\n"));
        t
        Gamma>

Task 2:

        Gamma> init_ipc("second","Q2");
        t
        Gamma> getpid();
        9092
        Gamma> next_event
        Are you there?
        t
        Gamma>

See the Starting Programs section of the Common Functions chapter (Tutorial One), or the Starting Programs section of the Common Functions for Any Program chapter (Tutorial Two), or the Common: Controlling the Cascade TextLogger section of the Log Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

## See Also

`locate_task_id`

Prev | Home | Next
`isend` | Up | `locate_task_id`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.