71 {
72
73
74 MsgStream log(
msgSvc(), name());
75 log << MSG::INFO << " BesVisAlg initialize()" << endreq;
76 StatusCode status = StatusCode::SUCCESS;
77
78
79
80 IService* isvc = 0;
81 status = serviceLocator()->service("RootCnvSvc", isvc, false);
82 if ( !status.isSuccess() )
83 status = serviceLocator()->service("EventCnvSvc", isvc, true);
84 if ( status.isSuccess() )
86 status = hasWrite();
87 if ( status.isSuccess()){
88 log << MSG::INFO << "share file writed -- success"
89 << endreq;
90 }
91 else {
92 log << MSG::ERROR << "share file writed -- ERROR!!!!!"
93 << endreq;
94 }
95
96
97
98 log << MSG::INFO << " OutputFile = " << f_rootOutputFile << endreq;
99
100 for (unsigned int i=0; i<testVec.size(); i++) {
101 log << MSG::INFO << " MyStringVec[" << i << "] = "
102 << testVec[i] << endreq;
103 }
104
105
106 m_pid = getpid();
107 log << MSG::ERROR << "BesVisAlg process PID: [" << m_pid << "]"
108 << endreq;
109
110 log << MSG::ERROR << "Create and initialize semaphore" << endreq;
111 if ((semid = semget((int)m_pid, 2, IPC_CREAT | IPC_EXCL | 0666)) != -1){
112 arg.
array = start_val;
113 log << MSG::ERROR << "Semaphore ID:" << semid << endreq;
114
115 if (semctl(semid, 0, SETALL, arg) == -1){
116 log << MSG::ERROR << "semctl -- parent -- initialization"
117 << endreq;
118 exit(1);
119 }
120
121 if ((sem_value_F = semctl(semid,
FREE_SPACE, GETVAL, 0)) == -1){
122 log << MSG::ERROR << "semctl -- GETVAL" << endreq;
123 exit(1);
124 }
125
126 if ((sem_value_O = semctl(semid,
OUTPUT_STORE, GETVAL, 0)) == -1){
127 log << MSG::ERROR << "semctl -- GETVAL" << endreq;
128 exit(1);
129 }
130 }
131 else {
132 log << MSG::INFO << "semget -- parent -- creation" << endreq;
133 exit(2);
134 }
135
136
137
138
139
140
141
142
143 if ((c_pid = fork()) == -1){
144 log << MSG::ERROR << "fork -- consumer" << endreq;
145 exit(5);
146 }
147 else if (c_pid == 0){
148
149 log << MSG::INFO << "Parent fork consumer: ppid = " << getppid()
150 << "; pid = " << getpid() << endreq;
151
152
153 char msg_pid[25];
155
156 const char *msg_sleep = testVec[1].c_str();
157
158 log << MSG::INFO << "msg_pid: " << msg_pid << endreq;
159 log << MSG::INFO << "Consumer sleep time: " << msg_sleep
160 << " seconds." << endreq;
161
162
163 execlp("besvis.exe", "besvis.exe",
164 "-B", msg_pid, "-e", f_rootOutputFile.c_str(),
165 "-g", f_geoInputFile.c_str(), (char *)NULL );
166
167
168 log << MSG::ERROR << "exec -- consumer" << endreq;
169 exit(6);
170 }
171
172
173 return StatusCode::SUCCESS;
174}
const InterfaceID IID_IRootCnvSvc
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)