본문으로 바로가기

백그라운드 실행 패키지 'jobexec'

category Tcl & Tk/팁 (Tip) 2025. 3. 14. 12:24

출처: http://tclrep.cvs.sourceforge.net/viewvc/tclrep/modules/jobexec/jobsched...

저는 주로 백그라운드 실행을 위해 blt의 bgexec를 이용했습니다. 별 탈없이 사용하다 며칠 전 bgexec에 버그가 있는 것을 발견했습니다. 예로 라이선스 프로그램 중의 하나인 flexlm인데요. 이 flexlm이 서버에 설치되어 있고, 클라이언트에서 라이선스 체크를 하려 하면, bgexec를 사용한 프로세스에서는 라이선스 체커가 동작하지 않는 문제가 발생했습니다. 원인 파악은 되고 있지 않지만, 궁여지책으로 순수 tcl로 구현된 bgexec가 있지 않을까 싶어 검색을 해본 결과 쓸만한 놈을 발견하였습니다.

 

이름하여 jobexec 라는 패키지입니다. 이 패키지는 tclrep 확장 패키지의 일부로 포함되어 있는 작은 패키지입니다. 테스트해본 결과 문제없이 정상 동작하였기에 첨부파일과 함께 테스트 코드를 올려봅니다. 참고로 이 jobexec 패키지는 프로세스의 강제 종료를 위해 Tclx 확장 패키지 내의 kill 커맨드를 이용합니다.

테스트 코드

source jobexec.tcl

package require jobexec

proc log {job msg} {
        puts $msg
}

proc output {job msg} {
        puts ">> $msg"
}

set job [jobexec create %AUTO%]
$job configure -command "par.bat"
$job configure -inbackground 1
$job configure -verbose 0
$job configure -loggercommand log
$job configure -onoutputcmd output
$job configure -internalbuffering 0
#$job configure -internalbuffersize 1
$job execute
$job waitend

#$job kill
$job destroy

결과 화면

......
>>    unrelated logic into a slice once 99% of the slices are occupied through
>>    related logic packing.
>>
>>    Note that once logic distribution reaches the 99% level through related
>>    logic packing, this does not mean the device is completely utilized.
>>    Unrelated logic packing will then begin, continuing until all usable LUTs
>>    and FFs are occupied.  Depending on your timing budget, increased levels o
f
>>    unrelated logic packing may adversely affect the overall timing performanc
e
>>    of your design.
>>
>> Mapping completed.
>> See MAP report file "fpga0.mrp" for details.
>> STEP 3 (par)
>> "C:\Xilinx\11.1\ISE\bin\nt\par.exe  fpga0.ncd fpga0.ncd fpga0.pcf"
>> Release 11.1 - par L.33 (nt)
>> Copyright (c) 1995-2009 Xilinx, Inc.  All rights reserved.
>>
>>
>> ERROR:Par:76 - Output file "fpga0.ncd" already exists.  Please specify -w to
overwrite.
......

프로세스 킬

Linux: kill -INT pid
Windows: kill -t pid

다운로드

jobexec.tcl
0.03MB
kill.7z
0.02MB