SMTHREAD_T(SSM )

Shore Programmer's Manual - 2 August 96

NAME

smthread_t \- SSM Thread Class

SYNOPSIS


#include <sm_vas.h>  // which includes smthread.h

class smthread_t : public sthread_t {
public:
    NORET			smthread_t(
	priority_t 		    priority = t_regular,
	bool 			    block_immediate = false, 
	bool 			    auto_delete = false,
	const char* 		    name = 0,
	long 			    lockto = WAIT_FOREVER);

    NORET			~smthread_t();

    virtual void 		run();
    
    void 			attach_xct(xct_t* x);
    void 			detach_xct(xct_t* x);
    xct_t* 			xct() const;
    static smthread_t* 		me();

    // set and get lock_timeout value
    long 			lock_timeout() const;
    void 			lock_timeout(long i);

    /*
     *  These methods are used to verify than nothing is
     *  left pinned accidentally.  Call mark_pin_count before an
     *  operation and check_pin_count after it with the expected
     *  number of pins that should not have been released.
     */
    void 			mark_pin_count();
    void 			check_pin_count(int change);
    void 			check_actual_pin_count(int actual) ;
    void 			incr_pin_count(int amount) ;
   
    /*
     *  These methods are used to verify that a thread
     *  is only in one ss_m::, scan::, or pin:: function at a time.
     */
    void 			in_sm(bool in);
    bool 			is_in_sm() const;

private:
    void			user(); /* disabled sthread\_t::user */
};


DESCRIPTION

Class smthread_t inherits from sthread_t, and extends it for use by the higher layers of the Shore Storage Manager. Any thread calling methods documented in ssm section manual pages (see intro(ssm) for a list) must be an smthread_t or derived from it.

sthread_t(priority, block_immediate, auto_delete, name, lock_timout)

See sthread_t(sthread) for details on the priority, block_immediate, auto_delete and name parameters. The lock_timout parameter specifies the default for how long a lock request by the smthread should block before it times out.

run()

This method is the body of the thread. See sthread_t(sthread) for more details. User should provide their own method to override this method.

Transaction Related Methods

Threads often run on behalf of a transaction, so there are methods for associating a thread with a transaction. For more information on transactions, see transaction(ssm)

attach_xct(xct)

The attach_xct method attaches the thread to transaction xct. Any SSM operation, performed by this thread, that requires transaction information will use the xct transaction. For example, all locks acquired by operations will be for the xct transaction. The ss_m::begin_xct method automatically calls attach_xct. It is a fatal error to call attach_xct if the thread is already attached to a transaction.

In general, only one thread can operate on behalf of a given transaction at any time (in other words, at most thread can be attached to a given transaction). The reason for this is that latch-latch deadlocks and latch-lock deadlocks are possible when two or more threads are operating on the same page, because locking does not provide concurrency control between threads. If, however, the value-added server writer takes responsibility for seeing that no such concurrency occurs, and rollback do not occur when two or more threads are attached to the same transaction, then (limited) parallelization of a transaction can be implemented.

detach_xct(xct)

The detach_xct method detaches the thread from transaction xct. It is a fatal error if the thread is not already attached to xct.

xct()

The xct method returns the transaction to which the thread is currently attached.

ERRORS

TODO

EXAMPLES

See Writing Value-Added Servers with the Shore Storage Manager for an example of how to use threads in a server.

VERSION

This manual page applies to Version 1.0 of theShore software.

SPONSORSHIP

The Shore project is sponsored by the Advanced Research Project Agency, ARPA order number 018 (formerly 8230), monitored by the U.S. Army Research Laboratory under contract DAAB07-92-C-Q508.

COPYRIGHT

Copyright (c) 1994, 1995, 1996 Computer Sciences Department, University of Wisconsin -- Madison. All Rights Reserved.

SEE ALSO

intro(sthread) sthread_t(sthread) transaction(ssm) lock(ssm)