02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5<br />

Shell<br />

side expression of the assignment statement. The shell prints a message indicating<br />

that a new variable has been allocated and assigned the specified value.<br />

For example, if the identifier fd is not currently in the symbol table, the following<br />

statement creates a new variable named fd and assigns to it the result of the<br />

function call:<br />

-> fd = open ("file", 0)<br />

5<br />

5.3.7 Comments<br />

The shell allows two kinds of comments. First, comments of the form /* … */ can<br />

be included anywhere on a shell input line. These comments are simply discarded,<br />

and the rest of the input line evaluated as usual. Second, any line whose first<br />

nonblank character is # is ignored completely. Comments are particularly useful<br />

for <strong>Tornado</strong> shell scripts. See the section Scripts: Redirecting Shell I/O, p.189 below.<br />

5.3.8 Strings<br />

When the shell encounters a string literal ("…") in an expression, it allocates space<br />

for the string including the null-byte string terminator. The value of the literal is<br />

the address of the string in the newly allocated storage. For instance, the following<br />

expression allocates 12 bytes from the target-agent memory pool, enters the string<br />

in those 12 bytes (including the null terminator), and assigns the address of the<br />

string to x:<br />

-> x = "hello there"<br />

Even when a string literal is not assigned to a symbol, memory is still permanently<br />

allocated for it. For example, the following uses 12 bytes of memory that are never freed:<br />

-> printf ("hello there")<br />

If strings were only temporarily allocated, and a string literal were passed to a<br />

routine being spawned as a task, then by the time the task executed and attempted<br />

to access the string, the shell would have already released—possibly even<br />

reused—the temporary storage where the string was held.<br />

This memory, like other memory used by the <strong>Tornado</strong> tools, comes from the targetagent<br />

memory pool; it does not reduce the amount of memory available for<br />

application execution (the VxWorks memory pool). The amount of target memory<br />

allocated for each of the two memory pools is defined at configuration time; see<br />

Scaling the Target Agent, p.141.<br />

183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!