CoreServer::Result CoreServer::test() { #ifdef INTEL if (m_info.coreId != 0) { FileSystemMessage msg; msg.type = ChannelMessage::Request; msg.action = StatFile; msg.path = (char *)0x12345678; msg.size = m_info.coreId; m_toMaster->write(&msg); } else { FileSystemMessage msg; Size numCores = m_cores->getCores().count(); for (Size i = 1; i < numCores; i++) { MemoryChannel *ch = (MemoryChannel *) m_fromSlave->get(i); if (!ch) return IOError; // TODO: replace with ChannelClient::syncReceiveFrom while (ch->read(&msg) != Channel::Success); if (msg.action == StatFile) { NOTICE("core" << i << " send a Ping"); } } } #endif /* INTEL */ return Success; }
void CoreServer::createProcess(FileSystemMessage *msg) { char cmd[128]; Memory::Range range; if (m_info.coreId == 0) { MemoryChannel *ch = (MemoryChannel *) m_toSlave->get(msg->size); if (!ch) { ERROR("invalid coreId=" << msg->size); msg->result = EBADF; return; } // TODO:move in libmpi? range.virt = (Address) msg->buffer; VMCtl(msg->from, LookupVirtual, &range); msg->buffer = (char *) range.phys; range.virt = (Address) msg->path; VMCtl(msg->from, LookupVirtual, &range); msg->path = (char *) range.phys; if (ch->write(msg) != Channel::Success) { ERROR("failed to write channel on core"<<msg->size); msg->result = EBADF; return; } DEBUG("creating program at phys " << (void *) msg->buffer << " on core" << msg->size); ch = (MemoryChannel *) m_fromSlave->get(msg->size); if (!ch) { ERROR("cannot find read channel for core" << msg->size); msg->result = EBADF; return; } // TODO: replace with ChannelClient::syncReceiveFrom while (ch->read(msg) != Channel::Success); DEBUG("program created with result " << (int)msg->result << " at core" << msg->size); msg->result = ESUCCESS; //IPCMessage(msg->from, API::Send, msg, sizeof(*msg)); ChannelClient::instance->syncSendTo(msg, msg->from); } else { VMCopy(SELF, API::ReadPhys, (Address) cmd, (Address) msg->path, sizeof(cmd)); range.phys = (Address) msg->buffer; range.virt = 0; range.access = Memory::Readable | Memory::User; range.size = msg->offset; VMCtl(SELF, Map, &range); pid_t pid = spawn(range.virt, msg->offset, cmd); int status; // reply to master msg->result = ESUCCESS; while (m_toMaster->write(msg) != Channel::Success); // TODO: temporary make coreserver waitpid() to save polling time waitpid(pid, &status, 0); } }