Ejemplo n.º 1
0
void BBSClient::save_args(int userid) {
#if defined(HAVE_PKMESG)
#if defined(HAVE_STL)
	int bufid = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkmesgbody(bufid);
	keepargs_->insert(
		pair<const int, int>(userid, bufid)
	);
	
#endif
	post_todo(working_id_);
#else
	int index, os;
	os = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkint(&working_id_, 1, 1);
	pvm_send(sid_, CRAY_POST_TODO);
	os = pvm_setsbuf(os);
	index = pvm_send(sid_, CRAY_POST_TODO);
	os = pvm_setsbuf(os);
#if defined(HAVE_STL)
	keepargs_->insert(
		pair<const int, int>(userid, os)
	);
	
#endif
#endif
}
Ejemplo n.º 2
0
void  BBSDirectServer::context(int ncids, int* cids) {
#if defined(HAVE_STL)
	int cid, j;
//printf("ncids=%d\n", ncids);
	if (remaining_context_cnt_ > 0) {
		printf("some workers did not receive previous context\n");
//		send_context_->clear();
		send_context_->erase(send_context_->begin(), send_context_->end());
		pvm_freebuf(context_buf_);
	}
	remaining_context_cnt_ = ncids;
	for (j = 0; j < ncids; ++j) {
		send_context_->insert(cids[j]);
	}
	LookingToDoList::iterator i = looking_todo_->begin();
	while (i != looking_todo_->end()) {
		cid = (*i);
		looking_todo_->erase(i);
//printf("sending context to already waiting %x\n", cid);
		pvm_send(cid, CONTEXT+1);
		--ncids;
		i = send_context_->find(cid);
		send_context_->erase(i);
		--remaining_context_cnt_;
		i = looking_todo_->begin();
	}
	if (remaining_context_cnt_ > 0) {
		context_buf_ = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	}else{
		pvm_freebuf(pvm_setsbuf(pvm_mkbuf(PvmDataDefault)));
	}
#endif
}
Ejemplo n.º 3
0
void BBSDirectServer::post_result(int id){
#if defined(HAVE_STL)
	WorkList::iterator i = work_->find(id);
	WorkItem* w = (WorkItem*)((*i).second);
// deal with following when thinking about error recovery
// at this time it was freed as a receive buffer after the take_todo
//	pvm_freebuf(w->bufid_);
	w->bufid_ = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	results_->insert(pair<const int, const WorkItem*>(w->parent_ ? w->parent_->id_ : 0, w));
#endif
}
Ejemplo n.º 4
0
void BBSDirect::save_args(int userid) {
#if defined(HAVE_STL)
	int bufid = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkmesgbody(bufid);
	keepargs_->insert(
		pair<const int, int>(userid, bufid)
	);
	
#endif
	BBSDirectServer::server_->post_todo(working_id_, mytid_);
	BBSDirectServer::handle();
}
Ejemplo n.º 5
0
void BBSDirectServer::post(const char* key) {
#if defined(HAVE_STL)
	int cid;
	int bufid = pvm_getsbuf();
//	printf("DirectServer::post |%s| bufid=%d\n", key, bufid);
	if (take_pending(key, &cid)) {
		pvm_send(cid, TAKE);
		pvm_freebuf(bufid);
	}else{
		MessageList::iterator m = messages_->insert(
		  pair<const char* const, const int>(newstr(key), bufid)
		);
	}
	pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
#endif
}
Ejemplo n.º 6
0
bool BBSDirectServer::look(const char* key) {
	bool b = false;
#if defined(HAVE_STL)
	MessageList::iterator m = messages_->find(key);
	if (m != messages_->end()) {
		b = true;
		int buf  = (*m).second;
		pvm_initsend(PvmDataDefault);
		pvm_pkmesgbody(buf);
		buf = pvm_getrbuf();
		pvm_setrbuf(pvm_setsbuf(pvm_mkbuf(PvmDataDefault)));
		pvm_freebuf(buf);
	}
//	printf("DirectServer::look %d |%s|\n", b, key);
#endif
	return b;
}
Ejemplo n.º 7
0
int pvm_initsend(int encoding)
{
  int newbufid;

#ifdef PVM_DEBUG
  PRINTF("Pe(%d) tid=%d:pvm_initsend(%d)\n",MYPE(),pvm_mytid(),encoding);
#endif
  if (CpvAccess(pvmc_sbufid) > 0)
    pvm_freebuf(CpvAccess(pvmc_sbufid));

  newbufid=pvm_mkbuf(encoding);

  if (newbufid<=0) {
    PRINTF("Pe(%d) tid=%d:%s:%d pvm_initsend() couldn't alloc new buffer\n",
	   MYPE(),pvm_mytid(),__FILE__,__LINE__);
  }
  CpvAccess(pvmc_sbufid)=newbufid;
  return CpvAccess(pvmc_sbufid);
}
Ejemplo n.º 8
0
void BBSClient::post_result(int id) {
#if debug
printf("BBSClient::post_result %d\n", id);
fflush(stdout);
#endif
	int index, os;
	os = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkint(&id, 1, 1);
#if defined(HAVE_PKMESG)
	pvm_pkmesg(os);
	index = pvm_send(sid_, POST_RESULT);
#else
	pvm_send(sid_, CRAY_POST_RESULT);
	os = pvm_setsbuf(os);
	index = pvm_send(sid_, CRAY_POST_RESULT);
#endif
	pvm_freebuf(os);
	if (index < 0) {perror("post_result");}
}
Ejemplo n.º 9
0
void BBSClient::post(const char* key) {
#if debug
printf("BBSClient::post |%s|\n", key);
fflush(stdout);
#endif
	int index, os;
	os = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkstr((char*)key);
#if defined(HAVE_PKMESG)
	pvm_pkmesg(os);
	index = pvm_send(sid_, POST);
#else
	pvm_send(sid_, CRAY_POST);
	os = pvm_setsbuf(os);
	index = pvm_send(sid_, CRAY_POST);
#endif
	pvm_freebuf(os);
	if (index < 0) {perror("post");}
}
Ejemplo n.º 10
0
void BBSDirectServer::post_todo(int pid, int cid){
#if defined(HAVE_STL)
	int bufid = pvm_getsbuf();
	WorkItem* w = new WorkItem(next_id_++, bufid, cid);
	WorkList::iterator p = work_->find(pid);
	if (p != work_->end()) {
		w->parent_ = (WorkItem*)((*p).second);
	}
	work_->insert(pair<const int, const WorkItem*>(w->id_, w));
	LookingToDoList::iterator i = looking_todo_->begin();
	if (i != looking_todo_->end()) {
		cid = (*i);
		looking_todo_->erase(i);
		// the send buffer is correct
		pvm_send(cid, w->id_ + 1);
		w->bufid_ = 0;
		pvm_freebuf(pvm_getsbuf());
	}else{
		todo_->insert(w);
	}
	pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
#endif
}