next up previous contents index
Next: 6.13 Asserting, Retracting, and Up: 6. Standard Predicates Previous: 6.11 Information about the   Contents   Index


6.12 Execution State

break

Causes the current execution to be suspended at the beginning of the next call. The interpreter then enters break level 1 and is ready to accept input as if it were at top level. If another call to break/0 is encountered, it moves up to break level 2, and so on. While execution is done at break level $n>0$ the prompt changes to $n$: ?-.

To close a break level and resume the suspended execution, the user can type the the atom end_of_file or the end-of-file character applicable on the system (usually CTRL-d on UNIX systems). Predicate break/0 then succeeds (note in the following example that the calls to break/0 do not succeed), and the execution of the interrupted program is resumed. Alternatively, the suspended execution can be abandoned by calling the standard predicate abort/0, which causes a return to the top level.

An example of break/0 's use is the following:


 		 		     | ?- break. 

1: ?- break.

2: ?- end_of_file.


yes
1: ?-

Entering a break closes all incomplete tables (those which may not have a complete set of answers). Closed tables are unaffected, even if the tables were created during the computation for which the break was entered.

halt
ISO
Exits the XSB session regardless of the break level. On exiting the system cpu and elapsed time information is displayed.

halt(Code)
ISO
Exits the XSB session regardless of the break level, sending the integer Code to the parent process. Normally 0 is considered to indicate normal termination, while other exit codes are used to report various degrees of abnormality.

Error Cases

prompt(+NewPrompt, ?OldPrompt)

Sets the prompt of the top level interpreter to NewPrompt and returns the old prompt in OldPrompt.

An example of prompt/2 's use is the following:


 		 		     | ?- prompt('Yes master > ', P). 


P = | ?- ;

no
Yes master > fail.

no
Yes master >

trimcore
machine
A call to trimcore/0 reallocates an XSB thread's execution stacks (and some tabling stacks) to their initial allocation size, the action affecting only the memory areas for the calling thread. When XSB is called in standalone or server mode, trimcore/0 is automatically called when the top interpreter level is reached. When XSB is embedded in a process, trimcore/0 is called at the top interpreter level for any thread created through xsb_ccall_thread_create() (see Volume 2, Chapter 3 Embedding XSB in a Process).

gc_heap

Explicitly invokes the garbage collector for a thread's heap. By default, heap garbage collection is called automatically for each thread upon stack expansion, unless the xsb_flag heap_garbage_collection is set to none. Automatic heap garbage collection should rarely need to be turned off, and should rarely need to be invoked manually.

cputime(-CPU_Time)

Returns the (process-level) CPU_Time at the time of the call in seconds. The difference between results of successive calls to this predicate can measure the time spent in specific predicates. Note that in the multi-threaded engine, cputime/1 measures the time for all threads.

walltime(-Time)

Returns the Time, in seconds, since execution started, or since the last call to statistics(0) by any thread.

statistics

Displays usage information on the current output stream, including:

As mentioned above, if XSB is configured with the single-threaded engine and is invoked with the '-s' option (see Section 3.7), additional information is printed out about maximum use of each execution stack and table space. However, the '-s' option can substantially slow down the emulator so benchmarks of time should be performed separately from benchmarks of space.

Example: The following printout shows how the statistics/0 output looks if it is invoked with the '-s' option (without it the Maximum stack used, and Maximum table space used lines are not shown). Information about the allocation size is provided since the sizes can be changed through emulator options (see Section 3.7).

| ?- statistics.
Memory (total)         2429504 bytes:       726696 in use,      1702808 free
  permanent space       645520 bytes:       645520 in use,            0 free
    atom                                    120328
    string                                  156872
    asserted                                  3184
    compiled                                358216
    other                                     6920
  glob/loc space        786432 bytes:          652 in use,       785780 free
    global                                     456 bytes
    local                                      196 bytes
  trail/cp space        786432 bytes:          476 in use,       785956 free
    trail                                       88 bytes
    choice point                               388 bytes
  SLG unific. space      65536 bytes:            0 in use,        65536 free
  SLG completion         65536 bytes:            0 in use,        65536 free
  SLG table space        80048 bytes:        80048 in use,            0 free

  Maximum stack used: global 436724, local 14780, trail 27304, cp 20292,
                      SLG completion 0 (0 subgoals)
  Maximum table space used:  0 bytes

Tabling Operations
  0 subsumptive call check/insert ops: 0 producers, 0 variants,
  0 properly subsumed (0 table entries), 0 used completed table.
  0 relevant answer ident ops.  0 consumptions via answer list.
  0 variant call check/insert ops: 0 producers, 0 variants.
  0 answer check/insert ops: 0 unique inserts, 0 redundant.


   0 heap (  0 string) garbage collections by copying: collected 0 cells in 0.000000 secs

Time: 0.190 sec. cputime,  13.921 sec. elapsetime

statistics(+Type)

statistics/1 allows the user to output detailed statistical information about the atom and symbol tables, as well as about table space. The following calls to statistics/1 are supported:


next up previous contents index
Next: 6.13 Asserting, Retracting, and Up: 6. Standard Predicates Previous: 6.11 Information about the   Contents   Index
Terrance Swift 2007-10-05