•  Back 
  •  General remarks about shutdown 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File11.5.9.4  Shutdown as seen by the initiator                        TOS

Shutdown and resolution change are taken on in MagiC by the program 
SHUTDOWN, which is called with the following parameters:

SHUTDOWN.PRG dev txt

For this dev = -1 if a Shutdown without a resolution change is to be 
performed, else = the device number of the VDI screen driver. txt is 
the text height for the AES; generally this should be 0.

A Shutdown is started with ret = shel_write(4, TRUE, 0, NULL, NULL). 
Here a return value of 0 signals that a Shutdown is not possible, 
because a Shutdown is already running, for instance. A resolution 
change is performed with ret = shel_write(5, dev, 0, NULL, NULL); here 
dev is the VDI device driver. Alternatively, one can specify a Falcon 
resolution mode in xdv with shel_write(5, xdv, 1, NULL, NULL).

These calls are all MultiTOS-conform. In addition, as of MagiC 3 the 
following call exists: ret = shel_write(5, dev, 100+txt, NULL, NULL). 
With this one can set the text height for the AES. One cannot pass a 
Falcon resolution with this mode, so dev is the device number of the 
VDI screen driver.

The device number depends on the system in use and the VDI. With a 
'naked' ST or TT030 (without graphics card) the following allocations 
apply:

 1  Default resolution 
 2  ST-Low              (320*200*16) 
 3  ST-Medium           (640*200*4) 
 4  ST-High             (640*400*2) 
 6  TT-Medium           (640*480*16) 
 8  TT-High             (1280*960*2) 
 9  TT-Low              (320*480*256) 

When using a graphics card, or on a Macintosh, the device numbers are 
found as usual in the ASSIGN.SYS file in the root directory of the 
boot drive.

After a successful shel_write call the system will be in the Shutdown 
mode and no more programs can be launched. On successful completion of 
the Shutdown or a resolution change the initiator receives the 
following message:

 msg[0] =  SHUT_COMPLETED
 msg[3] =  1 - Shutdown successful

or with a resolution change:

 msg[0] =  RESCH_COMPLETED
 msg[3] =  1 - Resolution change successful

Successful as far as the system is concerned means that all progams 
that understand AP_TERM have terminated themselves. If the Shutdown 
should be broken off nevertheless, then this can be done by using ret 
= shel_write(4, FALSE, 0, NULL, NULL). Otherwises a resolution change 
will be performed irrevocably when the initiator has terminated 
itself. On the other hand the Shutdown will be broken off when the 
initiator terminates.

If a program has refused a Shutdown with AP_TFAIL, then the initiator 
receives the following message:

 msg[0] =  SHUT_COMPLETED
 msg[3] =  0 - Break off Shutdown
 msg[4] =  ap_id of the application that has refused
 msg[5] =  Error-code of this application

bzw. beim Auflösungswechsel

 msg[0] =  RESCH_COMPLETED
 msg[3] =  0 - Resolution change broken off
 msg[4] =  ap_id of the application that has refused
 msg[5] =  Error-code of this application

In this case the system has already terminated the Shutdown or 
resolution change, i.e. the initiator cannot do anything any more.

Note: Because it is possible that the Shutdown process is never 
reported by the system as complete or broken off (the 
@{"RESCH_COMPLETED" ignore} or SHUT_COMPLETED message is never sent), 
the initiator should forsee a timeout while waiting for the message. 
In that case the Shutdown must be broken off explicitly. With 
appl_search the initiator can test whether there are still programs 
active that do not understand AP_TERM explicitly.

See also:
Shutdown at the receiver   shel_write   Shutdown in MultiTOS 
Shutdown in MagiC