Changes between Version 36 and Version 37 of GraphicsApi


Ignore:
Timestamp:
Aug 7, 2014, 10:12:14 AM (10 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GraphicsApi

    v36 v37  
    1010== Graphics apps ==
    1111
    12 The most general way of providing graphics involves
    13 using a 'graphics app' program (separate from your main application).
     12Graphics are generated by a 'graphics app' program (separate from the main application).
    1413This graphics app must have the properties that:
    1514
     
    9897This can be done efficiently using shared memory.
    9998The BOINC library supplies the following functions to facilitate this:
     99
    100100{{{
    101101void* boinc_graphics_make_shmem(char* appname, int size);
     102}}}
     103Called from the main app.
     104Creates a shared memory segment of the given size.
     105 'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name).
     106
     107{{{
    102108void* boinc_graphics_get_shmem(char* appname);
    103109}}}
    104 `boinc_graphics_make_shmem()` (called from the main app) creates a shared memory segment of the given size.
    105 'appname' should be the name of this application (used to ensure uniqueness of the shared-memory segment name).
    106 `boinc_graphics_get_shmem()` (called from the graphics app) attaches to an existing segment.
     110Called from the graphics app.
     111Attaches to an existing segment.
    107112It must be called AFTER boinc_parse_init_data_file().
    108113
    109 The contents of the shared memory segment are up to you.
     114The contents of the shared memory segment are application-dependent;
     115typically it contains numeric information describing the state of the computation.
     116
    110117You may want to include the following items:
    111118{{{
     
    115122    double cpu_time;
    116123    BOINC_STATUS status;
     124    int countdown;
    117125};
    118126}}}
    119127
    120 This structure should be updated by the main app once per second,
     128These items should be updated by the main app once per second,
    121129using [BasicApi#timer boinc_set_timer_handler()].
    122130The items are:
    123  update_time:: The current time (dtime()).
    124 The graphics app should exit if the current time exceeds this by 5 seconds or so.
    125  fraction_done:: The last fraction done reported by the main app.
    126  cpu_time:: The current CPU time.
    127  status:: The BOINC status.  If the 'suspended' flag is set,
    128 the graphics app should stop changing its display,
    129 and instead display an "application suspended" message.
     131 update_time::
     132   The current time (dtime()).
     133   The graphics app should exit if the current time exceeds this by 5 seconds or so,
     134   so that it exits if the main app exits.
     135 fraction_done::
     136   The last fraction done reported by the main app.
     137 cpu_time::
     138   The current CPU time, as returned by '''boinc_worker_thread_cpu_time()'''.
     139 status::
     140   The BOINC status, as returned by '''boinc_get_status()'''.
     141   If the 'suspended' flag is set,
     142   the graphics app should stop changing its display,
     143   and instead show an "application suspended" message.
     144 countdown::
     145   See below.
    130146
    131147Keep in mind that multiple instances of the graphics app may run simultaneously;
     
    134150use a semaphore to synchronize access so that the graphics app
    135151doesn't see an inconsistent state.
     152
     153=== Efficiency ===
     154
     155Updating the shared memory structure uses CPU time,
     156and it's desirable to avoid this overhead if no graphics app is running.
     157
     158One way to do this is to include a '''countdown''' field in the shared memory structure, as above.
     159 * The graphics sets this to 5 (say) in its '''app_graphics_render()''' function.
     160 * The main app decrements this (if positive) once per second.
     161 * The main app updates the application-specific data in shared memory
     162   only when '''countdown''' is nonzero.
     163
     164See [ExampleApps the example application] for an example.
    136165
    137166=== Creating an icon for your applications ===