Common Software Services - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Common Software Services

Description:

Portability Aids: Assist in writing portable Makefiles, shell scripts, and programs ... portable shell scripts. Need to be able to write scripts that work ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 20
Provided by: leel174
Category:

less

Transcript and Presenter's Notes

Title: Common Software Services


1
Common Software Services
  • The Globus Project
  • Argonne National LaboratoryUSC Information
    Sciences Instutute
  • http//www.globus.org/

2
Common Services
  • Portability Aids Assist in writing portable
    Makefiles, shell scripts, and programs
  • Collection of fundamental modules
  • Module activation/deactivation
  • Portable thread library (POSIX subset)
  • Thread-safe and portable libc wrappers
  • Timed and periodic callbacks
  • Data object and error object management
  • Modules to manipulate lists, fifos, URLs,
  • The rest of the Globus Toolkit relies on
    globus_common
  • User can/should use these for maximum portability
    and convenience

3
Writing Portable Makefiles
  • Each development flavor has a file for inclusion
    in makefiles etc/makefile_header
  • defines settings used for CC, LD, etc.
  • three important defintions
  • CFLAGS ex -g -thread
  • LDFLAGS ex -L/usr/local/ssl/lib
  • LIBS ex -lpthreads -lsocket -lssl
  • also, the three definitions for each module is
    defined
  • GLOBUS_COMMON_CFLAGS,LDFLAGS,LIBS
  • GLOBUS_DUROC_RUNTIME_CFLAGS,LDFLAGS,LIBS
  • etc.

4
Writing portable shell scripts
  • Need to be able to write scripts that work
    anywhere, regardless of your path settings
  • The globus-sh-tools file defines variables with
    complete paths to gt100 commonlyused programs
    (Bourne shell syntax)
  • GLOBUS_SH_LS/bin/ls
  • GLOBUS_SH_GREP/usr/bin/grep
  • This can be sourced in your /bin/sh script
  • . GLOBUS_TOOLS_PATH/libexec/globus-sh-tools
  • The variables can then used in your script
  • GLOBUS_SH_GREP -i grid mydocument gt outputfile

5
globus_config.h
  • When Globus Toolkit is built, it runs extensive
    configuration checks. Much of this knowledge is
    stored in a globus_config.h file, which can be
    used by any program
  • Architecture type
  • Availability of particular header files
  • Availability of particular functions
  • Non-standard types or functions

6
Activation and Deactivation
  • globus_module_()
  • Functions for activation (initialization) and
    deactivation (shutdown)
  • Support for multiple independent activations and
    deactivations of a module through reference
    counting
  • Support for dependencies amongst modules
  • Support for thread-safe initialization
  • Modules can use atexit()...

7
globus_module_activate()
  • This function must be called, passing it the
    appropriate module descriptor, before calling any
    other functions in that module
  • globus_module_activate(GLOBUS_NEXUS_MODULE)
  • Returns GLOBUS_SUCCESS if the module was
    successfully activated
  • Simultaneous activations of the same module are
    handled correctly through serialization
  • The activated module is responsible for
    recursively activating all modules that it
    requires

8
globus_module_deactivate()
  • There must be a matching deactivation for each
    and every activation
  • globus_module_deactivate(GLOBUS_NEXUS_MODULE)
  • Returns GLOBUS_SUCCESS if the module was
    successfully activated
  • Can re-activate a module after it has been
    deactivated
  • For convenience, can deactivate all at once
  • globus_module_deactivate_all()

9
Threads
  • globus_thread_(), globus_mutex_(),
    globus_cond_()
  • Simple POSIX threads (pthreads) subset
  • Same arguments and semantics as pthreads
  • Simply change pthread to globus or
    globus_thread in the function name
  • Provides portability to pre-standard pthread
    libraries, and non-pthread based systems
  • Simple pass-through on systems with standard
    pthreads
  • Co-exists with programs using pthreads directly

10
Thread Management Functions
  • Subset of pthreads for creating and managing
    threads
  • globus_thread_create()
  • globus_thread_exit()
  • globus_thread_self()
  • globus_thread_equal()
  • globus_thread_once()
  • globus_thread_yield()
  • globus_threadattr_init(), _destroy()
  • globus_threadattr_setstacksize(),

11
Thread Specific Storage
  • Pthread functions for storing per-thread data
  • globus_thread_key_create()
  • globus_thread_key_delete()
  • globus_thread_setspecific()
  • globus_thread_getspecific()
  • These work with or without threads

12
Mutual Exclusion
  • Pthread functions for mutual exclusion
  • globus_mutex_init()
  • globus_mutex_destroy()
  • globus_mutex_lock()
  • globus_mutex_trylock()
  • globus_mutex_unlock()
  • These work with or without threads

13
Conditions
  • Condition variables for signaling between threads
  • globus_cond_init()
  • globus_cond_destroy()
  • globus_cond_wait()
  • globus_cond_signal()
  • globus_cond_broadcast()
  • These work with our without threads

14
Thread Block Callbacks
  • Layer on top of pthread functions, which allows
    callbacks to be triggered when a thread blocks
    via globus_cond_wait()
  • globus_thread_blocking_callback_push()
  • globus_thread_blocking_callback_pop()
  • globus_thread_blocking_callback_enable()
  • globus_thread_blocking_callback_disable()
  • globus_thread_blocking_will_block()
  • Used by common callback library

15
Threaded vs Non-threaded
  • Globus supports pthreads, cthreads, Solaris
    threads, and sproc
  • Also supports non-threaded applications
  • Most thread-related functions are stubbed out
  • If you write code carefully which uses the mutex,
    cond, and thread specific storage functions, if
    should work both threaded and non-threaded
  • Most Globus Toolkit APIs use an event driven
    approach, which works well either with or without
    threads

16
globus_libc
  • Wrappers around standard libc functions
  • Thread safe, even if underlying libc is not
  • Caveat Application must also use globus_libc to
    ensure thread safety
  • Same interface for threaded and non-threaded
  • POSIX reentrant functions (_r()) always work
  • Example globus_libc_gethostbyname_r()
  • Fixes or enhances some functions
  • Example globus_libc_gethostname() tries to
    figure out a fully qualified hostname despite
    system configuration

17
Callbacks
  • Driver for timed and periodic callbacks
  • globus_callback_register_oneshot()
  • globus_callback_register_periodic()
  • globus_callback_unregister()
  • globus_callback_poll()
  • All modules rely on this for periodic polling
  • Uses threads where possible
  • Uses thread blocking callbacks to guarantee
    progress even when callback blocks

18
Convenience Modules
  • globus_common also contains a small set of
    convenience modules
  • globus_fifo First-In-First-Out queue
  • globus_hashtable Hashtable
  • globus_list List functions
  • globus_symboltable Symbol table management
  • globus_url URL parsing
  • globus_strptime Y2K-compliant strptime()
  • globus_object
  • globus_error

19
globus_common exercises
  • Go to the common subdirectory
  • View the layout of the Makefile
  • View the documentation on the web
  • Unfortunately, globus_common docs are currently
    incomplete, but what we will cover today is
    available athttp//www.globus.org/common/
  • Follow instructions in the file README
Write a Comment
User Comments (0)
About PowerShow.com