Fix scheduling issue where time didn't advance if a host was always ready
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ echo "=== Step 1: Building simulation with coverage instrumentation ==="
|
|||||||
gcc src/sha256.c src/basic.c src/file_system.c src/byte_queue.c src/file_tree.c \
|
gcc src/sha256.c src/basic.c src/file_system.c src/byte_queue.c src/file_tree.c \
|
||||||
src/message.c src/tcp.c src/wal.c src/hash_set.c src/client.c \
|
src/message.c src/tcp.c src/wal.c src/hash_set.c src/client.c \
|
||||||
src/metadata_server.c src/chunk_server.c src/random_client.c src/main.c \
|
src/metadata_server.c src/chunk_server.c src/random_client.c src/main.c \
|
||||||
quakey/src/lfs.c quakey/src/lfs_util.c quakey/src/quakey.c \
|
quakey/src/mockfs.c quakey/src/quakey.c \
|
||||||
-o "$SIMULATION_BINARY" \
|
-o "$SIMULATION_BINARY" \
|
||||||
-Iquakey/include -Iinclude \
|
-Iquakey/include -Iinclude \
|
||||||
-Wall -Wextra -ggdb -O0 \
|
-Wall -Wextra -ggdb -O0 \
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
|
// Label associated to the process for debugging
|
||||||
|
// The string must have global lifetime
|
||||||
|
char *name;
|
||||||
|
|
||||||
// Size of the opaque state struct
|
// Size of the opaque state struct
|
||||||
int state_size;
|
int state_size;
|
||||||
|
|
||||||
|
|||||||
+16
-3
@@ -235,6 +235,8 @@ struct Host {
|
|||||||
// Pointer to the parent simulation object
|
// Pointer to the parent simulation object
|
||||||
Sim *sim;
|
Sim *sim;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
// Platform used by this host
|
// Platform used by this host
|
||||||
QuakeyPlatform platform;
|
QuakeyPlatform platform;
|
||||||
|
|
||||||
@@ -275,6 +277,7 @@ struct Host {
|
|||||||
int poll_timeout;
|
int poll_timeout;
|
||||||
|
|
||||||
b32 timedout;
|
b32 timedout;
|
||||||
|
b32 blocked;
|
||||||
|
|
||||||
// Current error number set by system call mocks
|
// Current error number set by system call mocks
|
||||||
int errno_;
|
int errno_;
|
||||||
@@ -886,6 +889,7 @@ static int split_args(char *arg, char **argv, int max_argc)
|
|||||||
static void host_init(Host *host, Sim *sim, QuakeySpawn config, char *arg)
|
static void host_init(Host *host, Sim *sim, QuakeySpawn config, char *arg)
|
||||||
{
|
{
|
||||||
host->sim = sim;
|
host->sim = sim;
|
||||||
|
host->name = config.name;
|
||||||
host->platform = config.platform;
|
host->platform = config.platform;
|
||||||
host->next_ephemeral_port = FIRST_EPHEMERAL_PORT;
|
host->next_ephemeral_port = FIRST_EPHEMERAL_PORT;
|
||||||
|
|
||||||
@@ -943,6 +947,7 @@ static void host_init(Host *host, Sim *sim, QuakeySpawn config, char *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
host->timedout = false;
|
host->timedout = false;
|
||||||
|
host->blocked = false;
|
||||||
host->poll_count = 0;
|
host->poll_count = 0;
|
||||||
host->poll_timeout = -1;
|
host->poll_timeout = -1;
|
||||||
|
|
||||||
@@ -1019,6 +1024,9 @@ static bool is_desc_idx_valid(Host *host, int desc_idx);
|
|||||||
|
|
||||||
static bool host_ready(Host *host)
|
static bool host_ready(Host *host)
|
||||||
{
|
{
|
||||||
|
if (host->blocked)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (host->timedout)
|
if (host->timedout)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -2170,15 +2178,20 @@ static b32 sim_update(Sim *sim)
|
|||||||
if (host_idx > -1)
|
if (host_idx > -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (sim->num_events == 0)
|
for (int i = 0; i < sim->num_hosts; i++)
|
||||||
__builtin_trap(); // TODO: remove me
|
sim->hosts[i]->blocked = false;
|
||||||
|
|
||||||
advance_time_to_next_event(sim);
|
advance_time_to_next_event(sim);
|
||||||
process_events_at_current_time(sim);
|
process_events_at_current_time(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
move_host_to_last(sim, host_idx);
|
move_host_to_last(sim, host_idx);
|
||||||
host_update(sim->hosts[sim->num_hosts-1]);
|
|
||||||
|
Host *host = sim->hosts[sim->num_hosts-1];
|
||||||
|
host_update(host);
|
||||||
|
if (host_ready(host))
|
||||||
|
host->blocked = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -36,7 +36,8 @@ typedef pthread_mutex_t Mutex;
|
|||||||
|
|
||||||
#define PARALLEL_LIMIT 5
|
#define PARALLEL_LIMIT 5
|
||||||
|
|
||||||
#define CLIENT_TRACE(fmt, ...) fprintf(stderr, "CLIENT: " fmt "\n", ##__VA_ARGS__);
|
#define CLIENT_TRACE(fmt, ...) {}
|
||||||
|
//#define CLIENT_TRACE(fmt, ...) fprintf(stderr, "CLIENT: " fmt "\n", ##__VA_ARGS__);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SHA256 hash;
|
SHA256 hash;
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ int main(void)
|
|||||||
// Client
|
// Client
|
||||||
{
|
{
|
||||||
QuakeySpawn config = {
|
QuakeySpawn config = {
|
||||||
|
.name = "client",
|
||||||
.state_size = sizeof(RandomClient),
|
.state_size = sizeof(RandomClient),
|
||||||
.init_func = random_client_init,
|
.init_func = random_client_init,
|
||||||
.tick_func = random_client_tick,
|
.tick_func = random_client_tick,
|
||||||
@@ -146,6 +147,7 @@ int main(void)
|
|||||||
// Metadata Server
|
// Metadata Server
|
||||||
{
|
{
|
||||||
QuakeySpawn config = {
|
QuakeySpawn config = {
|
||||||
|
.name = "ms",
|
||||||
.state_size = sizeof(MetadataServer),
|
.state_size = sizeof(MetadataServer),
|
||||||
.init_func = metadata_server_init,
|
.init_func = metadata_server_init,
|
||||||
.tick_func = metadata_server_tick,
|
.tick_func = metadata_server_tick,
|
||||||
@@ -161,6 +163,7 @@ int main(void)
|
|||||||
// Chunk Server
|
// Chunk Server
|
||||||
{
|
{
|
||||||
QuakeySpawn config = {
|
QuakeySpawn config = {
|
||||||
|
.name = "cs",
|
||||||
.state_size = sizeof(ChunkServer),
|
.state_size = sizeof(ChunkServer),
|
||||||
.init_func = chunk_server_init,
|
.init_func = chunk_server_init,
|
||||||
.tick_func = chunk_server_tick,
|
.tick_func = chunk_server_tick,
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "metadata_server.h"
|
#include "metadata_server.h"
|
||||||
|
|
||||||
#define MS_TRACE(fmt, ...) fprintf(stderr, "MS: " fmt "\n", ##__VA_ARGS__);
|
#define MS_TRACE(fmt, ...) {}
|
||||||
|
//#define MS_TRACE(fmt, ...) fprintf(stderr, "MS: " fmt "\n", ##__VA_ARGS__);
|
||||||
|
|
||||||
static void chunk_server_peer_init(ChunkServerPeer *chunk_server, Time current_time)
|
static void chunk_server_peer_init(ChunkServerPeer *chunk_server, Time current_time)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user