Check out the new USENIX Web site. next up previous
Next: Implementation Issues Up: Overview of Rhino Previous: Rhino Structure

   
Application Programming in Rhino

Database files managed by Rhino are accessed either by user-space applications or by other in-kernel extensions. For ease of use and understanding, we use C nomenclature to present interfaces accessed by user-space applications.

Table 1 shows the system calls supported by Rhino. The system call interface resembles those found in other systems [#!rvm!#,#!odi!#,#!texas!#]. Figure 4 shows a simple application that writes ``z''s onto the region that extends from byte 256 to byte 384 in the file ``/efs/test''. To access a database file, the application first calls trans_open to get a handle to the file. It then calls trans_mmap to map the file onto a virtual address space region (that must be MMU-page aligned). After setup of the transactional memory region, the application need only demarcate transactions by using trans_begin, trans_commit, and trans_abort. Accesses to the transactional memory region are detected through page faults.[*]


 
Table: Rhino API
System Call Function
storage = trans_open( path) Opens the database file path
trans_close( storage) Closes the file
trans_setrange( storage, from, len)
Notifies the modification to Rhino. This system call exists only in one of the three alternative versions of buffer management.
trans_mmap( addr, length, storage) Maps the file onto caller's address space
trans_munmap( addr, length) Unmaps the file
trans_id = trans_begin() Begins a transaction
trans_commit( trans_id) Commits the transaction
trans_abort( trans_id) Aborts the transaction and rolls back its effect
 


main()
{
    tid_t tid;
    sid_t sid;
    void *base = (void*)0x10000;
    /* Open the file /efs/test. */
    sid = trans_open("/efs/test");
    /* Map the storage from 0x10000 .. 0x90000. */
    trans_mmap(base, 0x80000, sid);
  
    tid = trans_begin();
    /* Fill the region with "z". */
    memset(base + 256, 'z', 128);
    if (something_wrong()) trans_abort(tid);
    else trans_commit(tid);
}
  
Figure: Sample application in user space.


next up previous
Next: Implementation Issues Up: Overview of Rhino Previous: Rhino Structure
Yasushi Saito
1998-04-27