HPlogo DCE for the HP e3000 > Chapter 7 Programming with RPC 1.2.1 on MPE/iX

Compiling Multithreaded Application

MPE documents

Complete PDF
Table of Contents
Index

There are some new preprocessing directives that has been introduced to compile with latest Pthread implementation.

_POSIX_SOURCE: This needs to be used when compiling any DCE application. It is not necessary when compiling threads-only application.

_MPE_THREADS: This is used when compiling any DCE or multithreaded application. This directive is used to set the thread specific errno.

Applications should ensure that they link /lib/libpthread.sl before /lib/libc.sl to ensure that they invoke the thread-safe versions of these C runtime. Applications should not use the c89 linking feature directly since it binds the C routines to /lib/libc.a before /lib/libpthread.sl. Since we are binding to /lib/libc.sl, we need to explicitly link the program object file(s) with the loader "start" routine.

The following makefile will provide an example of the linking process.

  DEBUG = -gINCENV = -I. -I/usr/include
  ANSI_FLAGS = -D_POSIX_SOURCE -D_POSIX_D10_THREADS
  MPE_FLAGS = -D_MPEXL_SOURCE -D_MPE_THREADS -DMPEXL
  CFLAGS = ${ANSI_FLAGS} ${DEBUG} ${MPE_FLAGS} ${INCENV}
  #LIBS = -lsocket -lsvipc -lm
  XL = /lib/libdce.sl, /lib/libpthread.sl, /lib/libc.sl
  PROGRAMS = server client
  server_OFILES = manager.o server.o sleeper_sstub.o
  client_OFILES = sleeper_cstub.o client.o
  IDLFLAGS = -keep c_source ${INCENV}
  IDLFILES = sleeper.idl
  IDLGEN = sleeper.h sleeper_*stub.c
  IDL = /SYS/HPBIN/SH /usr/bin/idl
  #IDL = /SYS/PUB/IDL

  all: objects ${PROGRAMS}

  objects: ${server_OFILES} ${client_OFILES}

  fresh: clean all

  clean:
          @-rm $(IDLGEN) $(server_OFILES) $(client_OFILES) $(PROGRAMS)

  server: ${server_OFILES}
          ar -rc server.obj ${server_OFILES}
          callci linkedit \" 'link from=/SYS/PUB/STARTO,\
            /Speedware/sleeper/server.obj;\
          to=/Speedware/sleeper/server;xl=${XL};posix;share'\"

  client: ${client_OFILES}
          ar -rc client.obj ${client_OFILES}
          callci linkedit \" 'link from=/SYS/PUB/STARTO,\
            /Speedware/sleeper/client.obj;\
          to=/Speedware/sleeper/client;xl=${XL};posix;share'\"

  sleeper.h: ${IDLFILES}
          $(IDL) ${IDLFLAGS} ${IDLFILES}

  sleeper_cstub.o sleeper_sstub.o manager.o server.o client.o: sleeper.h




Chapter 7 Programming with RPC 1.2.1 on MPE/iX


Index