void L2_cache :: release_mshr_entry(hash_entry* mshr_entry) { mshr_map[mshr_entry->get_idx()] = 0; mshr_entry->invalidate(); //check the stall buffer and see if any request waiting for mshr //std::list<std::pair <Coh_mem_req *, stall_type_t> >::iterator it = stalled_client_req_buffer.begin(); std::list<Stall_buffer_entry>::iterator it = stalled_client_req_buffer.begin(); Coh_msg* req = 0; manifold::kernel::Ticks_t stall_time; stall_type_t stallType; //for debug bool found = false; //if there's a stalled request to wake up while(it != stalled_client_req_buffer.end()) { //Wake up a stalled request only if it will not PREV_PEND_STALL, LRU_BUSY_STALL, or TRANS_STALL. //It canno MSHR_STALL because we are releasing an MSHR entry only a few lines ago. if (!mshr->has_match((*it).req->addr)) { //won't PREV_PEND if(!my_table->has_match ((*it).req->addr)) { //going to miss ManagerInterface* victim_manager = managers[my_table->get_replacement_entry ((*it).req->addr)->get_idx()]; if (victim_manager->req_pending() == false && mcp_stalled_req[victim_manager->getManagerID()] == 0) { found = true; } } else { //hit if (managers[my_table->get_entry((*it).req->addr)->get_idx()]->req_pending() == false) { //won't TRANS found = true; } } } if(found) { req = (*it).req; stall_time = (*it).time; stalled_client_req_buffer.erase(it); break; } ++it; } if(req != 0) { //do a sanity check paddr_t line_addr = my_table->get_line_addr(req->addr); for(std::list<Stall_buffer_entry>::iterator it = stalled_client_req_buffer.begin(); it != stalled_client_req_buffer.end(); ++it) { if(my_table->get_line_addr((*it).req->addr) == line_addr) { assert(stall_time <= (*it).time); //if a stalled request is for the same line, then it must be stalled later than the one //being released. } } DBG_L2_CACHE_ID(cout, " wakeup req, stall type= " << stallType << " req= " << req << " msg= " << req->msg << " addr= " <<hex<< req->addr <<dec << " src= " << req->src_id << "\n"); process_client_request(req, false); } }
//==================================================================== //==================================================================== void L2_cache :: process_incoming_coh(Coh_msg* request) { DBG_L2_CACHE_TICK_ID(cout, "###### handle_incoming()_coh, srcID= " << request->src_id << " type= " << int(request->type) << " addr=(" <<hex<< request->addr <<dec<< ")" << endl); if(request->type == Coh_msg :: COH_REQ) { stats_num_reqs++; //stats if(stalled_client_req_buffer.size() > stats_stall_buffer_max_size) stats_stall_buffer_max_size = stalled_client_req_buffer.size(); process_client_request(request, true); } else { assert(request->type == Coh_msg :: COH_RPLY); process_client_reply(request); } }
void L2_cache :: handle_incoming(int, Coh_mem_req* request) { #ifdef DBG_MCP_CACHE_L2_CACHE cout << "\n######## L2_cache node= " << node_id << " @ " << manifold::kernel::Manifold::NowTicks() << " handle_incoming(), srcID= " << request->get_src() << " type= " << request->type << " addr=(" <<hex<< request->u.mem.addr << " / " << request->u.coh.addr <<dec<< ")" << endl; #endif if(request->type == Coh_mem_req :: MEM_RPLY) { process_mem_resp(request); } else if(request->type == Coh_mem_req :: COH_REQ) { //stats if(stalled_client_req_buffer.size() > stats_stall_buffer_max_size) stats_stall_buffer_max_size = stalled_client_req_buffer.size(); process_client_request(request, true); } else { assert(request->type == Coh_mem_req :: COH_RPLY); process_client_reply(request); } }
void listen_for_requests() { char requestBuffer[512]; char responseBuffer[1024]; int connfd; int listenfd = tcp_listen(myPort); printf("Listening for Requests.\n"); while(TRUE) { memset(requestBuffer, '\0', sizeof(requestBuffer)); memset(responseBuffer, '\0', sizeof(responseBuffer)); connfd = accept(listenfd, (struct sockaddr*)NULL, NULL); read(connfd, requestBuffer, sizeof(requestBuffer)-1); int bufferSize = process_client_request(responseBuffer, requestBuffer); if(bufferSize > 0) { write(connfd, responseBuffer, bufferSize); } close(connfd); } }
void server_with_select(struct sockaddr_in *destination, bool dump_flag) { fd_set active_fd_set, read_fd_set; struct timeval timeout; int readsocks; int ii; FD_ZERO(&active_fd_set); FD_SET(_server_socket, &active_fd_set); highest_socket = _server_socket; while (1) { read_fd_set = active_fd_set; timeout.tv_sec = 1; timeout.tv_usec = 0; readsocks = select(highest_socket + 1, &read_fd_set, NULL, NULL, &timeout); for (ii = 0; ii < highest_socket + 1; ++ii) { if (FD_ISSET(ii, &read_fd_set)) { if (ii == _server_socket) { UDPClient *new_client; new_client = process_client_request(destination, dump_flag); if (new_client) { FD_SET(new_client->server_socket(), &active_fd_set); add_client(new_client); } } else { UDPClient *client; client = client_for_socket(ii); if (client) { listen_from_server(client); } } } } clean_up_clients(); } }
/** * \brief * \detailed * \param pvParameters - pointer to parameters */ static void handleHttpRequestsTask(void *pvParameters) { TickType_t xLastWakeTime; xLastWakeTime = xTaskGetTickCount(); char response, stringToPrint[30]; while (1) { response = process_client_request(); // get_next_client_response(); if (response != ' ' && response != '\0') { sprintf(stringToPrint, "Command: %c", response); displayToTerminal(stringToPrint); if (response == 'A') { setCommandMode(-2); } else if (response == 'C') { setCommandMode(-1); } else if (response == '0') { setCommandMode(STOP_MOVEMENT); } else if (response == '1') { setCommandMode(FORWARD_MOVEMENT); } else if (response == '2') { setCommandMode(BACKWARD_MOVEMENT); } else if (response == '3') { setCommandMode(ROTATE_LEFT_MOVEMENT); } else if (response == '4') { setCommandMode(ROTATE_RIGHT_MOVEMENT); } else if (response == '5') { setCommandMode(5); } else if (response == '6') { setCommandMode(6); } } vTaskDelayUntil(&xLastWakeTime, (5000 / portTICK_PERIOD_MS)); } }
void process_client_request_np(void* arg) { process_client_request(arg); }
/* Only used for client requests, TCP ???*/ void process_connection(int ci) { struct boothc_ticket_msg msg; int rv, len, expr, fd; void (*deadfn) (int ci); fd = clients[ci].fd; rv = do_read(fd, &msg.header, sizeof(msg.header)); if (rv < 0) { if (errno == ECONNRESET) log_debug("client %d connection reset for fd %d", ci, clients[ci].fd); goto kill; } if (check_boothc_header(&msg.header, -1) < 0) goto kill; /* Basic sanity checks already done. */ len = ntohl(msg.header.length); if (len) { if (len != sizeof(msg)) { bad_len: log_error("got wrong length %u", len); return; } expr = len - sizeof(msg.header); rv = do_read(clients[ci].fd, msg.header.data, expr); if (rv < 0) { log_error("connection %d read data error %d, wanted %d", ci, rv, expr); goto kill; } } /* For CMD_GRANT and CMD_REVOKE: * Don't close connection immediately, but send * result a second later? */ switch (ntohl(msg.header.cmd)) { case CMD_LIST: ticket_answer_list(fd, &msg); goto kill; case CMD_GRANT: case CMD_REVOKE: /* Expect boothc_ticket_site_msg. */ if (len != sizeof(msg)) goto bad_len; process_client_request(&clients[ci], &msg); return; default: log_error("connection %d cmd %x unknown", ci, ntohl(msg.header.cmd)); init_header(&msg.header, CL_RESULT, 0, 0, RLT_INVALID_ARG, 0, sizeof(msg.header)); send_header_only(fd, &msg.header); goto kill; } assert(0); return; kill: deadfn = clients[ci].deadfn; if(deadfn) { deadfn(ci); } return; }