[Migrated content. Thread originally posted on 20 February 2012]
Hi,i am having trouble on running a simple cobol procedure to be accessed from solaris thread simultaneously.
for simplicity i took demo program c-cobol for this task here is the source code for cobol:
copy "cmain1.cpy".
IDENTIFICATION DIVISION.
PROGRAM-ID. cobsub1.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
WORKING-STORAGE SECTION.
01 yyy pic x.
01 zzz char redefines yyy.
LINKAGE SECTION.
01 param param1.
PROCEDURE DIVISION using by reference param.
* display "In cobsub1.cbl"
move 10.5 to a
move 10 to b
move 10 to c
move "a" to yyy
move zzz to d
here is c program accessing cobol:
#include
#include
#include "cobmain.h"
#include "cobcall.h"
#include "cmain1.h"
void* main_function(void* a )
{
struct param1 param;
struct param2 paramb;
char text[80];
void * ptr;
int id = *((int*)a);
while(1)
{
sleep(1);
printf("ID: %d:In C main1\\n",id);
param.a = 0;
param.b = 0;
param.c = 0;
param.d = '\\0';
ptr = (void*)¶m;
cobcall((cobchar_t*)"cobsub1", 1, (cobchar_t**)&ptr);
if((param.a == 10.5) && (param.b == 10) &&
(param.c == 10) && (param.d == 'a'))
printf("Id:%d:PASS\\n",id);
else
printf("Id:%d:FAIL\\n",id);
printf("Id:%d:Bye\\n",id);
}
return 0;
}
int main()
{
int i =1;
int j =2;
thread_t thrid;
cobinit();
printf("Create thread 1\\n");
thr_create(0,0,main_function,&i,0,&thrid);
printf("Create thread 2\\n");
thr_create(0,0,main_function,&j,0,&thrid);
printf("Join thread 2\\n");
while(1)sleep(10);
return 0;
}
here is the makefile for building application
all:
h2cpy -I /usr/include cmain1.h
cob -xv -o cmain1 -CC -I${COBDIR}/include cmain1.c cobsub1.cbl -lthread -U
clean:
rm -f *.int *.so *.o core *.ext cmain1 *.idy *.lst
And additionally using reentrant"2" as compiler directive.
When i run this application, it executes 10-15 times after that
"rts64: Fatal Error while attempting to process error 200" error message is received and core dumped.
In short what are the compiler flags to build a native C/Cobol program to build a multithreaded C application that accesses Cobol procedure.