× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am trying to multi-thread the creation of some qtemp objects, but its
not working as it should be. I did check and CRTDUPOBJ is thread safe.

I have a file which contains a list of objects that I need to create in
qtemp, now I have tested this without using the multi-threading code and
everything works fine, so it has something to do with the multi-threading
portion.

Any help would be greatly appreciated.


0001.00 HOPTION(*NODEBUGIO:*SRCSTMT:*noshowcpy:*NOUNREF)
0002.00 Hdftactgrp(*NO) THREAD(*CONCURRENT)
0003.00
0004.00 /copy qsysinc/qrpglesrc,pthread
0004.01 /copy qsysinc/qrpglesrc,errno
0005.00
0012.00
0012.02 D THREAD_COUNT c 1
0012.03
0012.04 D Sleep pr 10u 0 extproc('sleep')
0012.05 D secs 10u 0 value
0012.08
0012.09 D qCmdExc pr Extpgm('QCMDEXC')
0012.10 D cmd 200a options(*varsize) const
0012.11 D cmdlen 15 5
0012.12
0012.13 D qcmd s 200a
0012.14 D qcmdlen s 15 5 Inz(0)
0012.15
0012.21
0013.00 D thr_id ds likeds(pthread_t)
0013.01 D* dim(THREAD_COUNT)
0013.02 D err s 10i 0
0013.03 D x s 10i 0
0013.04 D y s 10i 0
0014.00
0015.00 /Free
0015.09 // For x = 1 to THREAD_COUNT;
0015.11 err = pthread_create( thr_id
0015.12 : *omit
0015.13 : %pAddr(MyProcPF)
0015.14 : *Null );
0015.15 // MyProcPF();
0015.16 If (err <> 0);
0015.17 Endif;
0015.18 // EndFor;
0015.19
0015.20 // for x = 1 to THREAD_COUNT;
0015.21 pthread_join( thr_id : *omit );
0015.22 //EndFor;
0015.23
0015.24 *Inlr = *On;
0016.00 /End-Free
0017.00
0017.01 P MyProcPF b
0017.02 Ffilelist if e k Disk Qualified
0017.03 F Static
0017.04 D pi
0017.05 D Create_parm * Value
0017.06 D MyDs ds LikeRec(FileList.rFileList)
0017.07 D Mytype s 2a Inz('PF')
0017.08 D MyError s 10i 0
0017.09
0017.10 /Free
0017.11 Setll (MyType) FileList;
0017.12 Reade (MyType) FileList MyDs;
0017.13 Dow Not %Eof(FileList);
0017.14 qCmd = 'CRTDUPOBJ OBJ(' + MyDs.FileName + ') +
0017.15 FROMLIB(*LIBL) OBJTYPE(*FILE) TOLIB(QTEMP)';
0017.16 qCmdLen = %Len(%Trim(qCmd));
0017.17 MyError = qCmdExc (qcmd: qCmdLen);
0017.18 Reade (MyType) FileList MyDs;
0017.19 EndDo;
0017.20 // Sleep(30);
0017.21 // return *Null;
0017.22 /End-Free
0017.23
0017.24 P MyProcPF e
0021.00


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.