/********************************************************************** * Restore the task priority to original value. * See the ceiling protocol of the OSEK/VDX standart. * * @param ID IN ID of the resource to be accessed * @return Status E_OS_ACCESS if the resource does not exist * Elsewise the function never returns **********************************************************************/ StatusType ReleaseResource(ResourceType ID) { if (ID >= RESOURCENUMBER) return (E_OS_ID); if (Resource_list[ID].lock == 0) return E_OS_ACCESS; SetPriority(Resource_list[ID].Taskprio, id_tsk_run); Resource_list[ID].lock = 0; Organize(); return(E_OK); }
/********************************************************************** * Set the task priority to the resource priority. * See the ceiling protocol of the OSEK/VDX standart. * * @param ID IN ID of the resource to be accessed * @return Status E_OS_ACCESS if the resource does not exist * Elsewise the function never returns **********************************************************************/ StatusType GetResource(ResourceType ID) { if (ID >= RESOURCENUMBER) return (E_OS_ID); if (Resource_list[ID].lock == 1) return E_OS_ACCESS; GetPriority(&Resource_list[ID].Taskprio, id_tsk_run); SetPriority(Resource_list[ID].priority, id_tsk_run); Resource_list[ID].lock = 1; Organize(); return(E_OK); }
void Print(const T &lattice , U nx , U ny) { auto depth = lattice.at(0).size(); auto code = depth + lattice.size() % (nx * ny); // 2 for depth 2, 9 for depth 9, default for boundary switch (code) { case 2: { int counter = 0; auto flipped_lattice = Flip(lattice, nx); for (auto node : flipped_lattice) { std::cout << std::fixed << std::setprecision(2) << node[0] << " " << node[1] << " "; if (++counter % nx == 0) { std::cout << std::endl; counter = 0; } } // lat std::cout << std::endl; break; } case 9: { auto lat = Flip(Organize(lattice), nx); // row of lattice for (auto y = 0u; y < ny; ++y) { // rows in the Q9 square for (auto i = 0u; i < depth / 3; ++i) { // column of lattice for (auto x = 0u; x < nx; ++x) { auto n = y * nx + x; auto index = i * 3; std::cout << std::fixed << std::setprecision(2) << lat[n][index] << " " << lat[n][index + 1] << " " << lat[n][index + 2] << " "; } // x std::cout << std::endl; } // i std::cout << std::endl; } // y std::cout << std::endl; break; } default: { std::vector<U> length = {ny, ny, nx, nx, 4}; auto lat = Organize(lattice); // row of boundary, print 4 lines, left, right, top, bottom and corners for (auto y = 0u; y < 5; ++y) { // rows in the Q9 square for (auto i = 0u; i < depth / 3; ++i) { // column of lattice for (auto x = 0u; x < length[y]; ++x) { auto n = 2 * ny + 2 * nx + x; auto index = i * 3; if (y == 0 || y == 1) n = y * ny + x; if (y == 2 || y == 3) n = 2 * ny + (y - 2) * nx + x; std::cout << std::fixed << std::setprecision(2) << lat[n][index] << " " << lat[n][index + 1] << " " << lat[n][index + 2] << " "; } // x std::cout << std::endl; } // i std::cout << std::endl; } // y std::cout << std::endl; break; } } }