(update_main): No longer a thread entry point. Remove the parameter.
Remove *player setup. Don't terminate the thread when done.
(update_pending): Move to src/server/update.c.
(update_wait): Call update_main() instead of running it in its own
thread. Set up *player for it.
(update_init): Create the fused update thread instead of the update
wait thread.
void market_update(void *);
void mobility_check(void *);
void player_kill_idle(void *);
void market_update(void *);
void mobility_check(void *);
void player_kill_idle(void *);
-void update_main(void *);
void update_init(void);
void shutdown_sequence(void *);
void update_force(void *);
void update_init(void);
void shutdown_sequence(void *);
void update_force(void *);
long air_money[MAXNOC];
long tpops[MAXNOC];
long air_money[MAXNOC];
long tpops[MAXNOC];
-int update_pending = 0;
-
-/*ARGSUSED*/
-update_main(void *unused)
{
int etu = etu_per_update;
int n;
{
int etu = etu_per_update;
int n;
struct natstr *cnp;
struct natstr *np;
struct natstr *cnp;
struct natstr *np;
- if (CANT_HAPPEN(!update_pending))
- update_pending = 1;
-
logerror("production update (%d etus)", etu);
journal_update(etu);
logerror("production update (%d etus)", etu);
journal_update(etu);
mob_plane(etu);
mob_land(etu);
}
mob_plane(etu);
mob_land(etu);
}
- player->proc = empth_self();
- player->cnum = 0;
- player->god = 1;
if (opt_AUTO_POWER)
update_power();
if (opt_AUTO_POWER)
update_power();
/* Clear all the telegram flags */
for (cn = 0; cn < MAXNOC; cn++)
clear_telegram_is_new(cn);
/* Clear all the telegram flags */
for (cn = 0; cn < MAXNOC; cn++)
clear_telegram_is_new(cn);
- player_delete(player);
- empth_exit();
- /*NOTREACHED*/
empth_sem_t *update_sem;
empth_rwlock_t *update_lock;
empth_sem_t *update_sem;
empth_rwlock_t *update_lock;
time_t update_time;
static void update_sched(void *);
time_t update_time;
static void update_sched(void *);
+ struct player *dp;
+ int stacksize;
+
update_sem = empth_sem_create("Update", 0);
update_lock = empth_rwlock_create("Update");
if (!update_sem || !update_lock)
exit_nomem();
update_sem = empth_sem_create("Update", 0);
update_lock = empth_rwlock_create("Update");
if (!update_sem || !update_lock)
exit_nomem();
- if (!empth_create(PP_SCHED, update_wait, 50 * 1024, 0,
- "UpdateWait", "Waits until players idle", NULL))
+ dp = player_new(-1);
+ if (!dp)
+ exit_nomem();
+ /* FIXME ancient black magic; figure out true stack need */
+ stacksize = 100000 +
+/* finish_sects */ WORLD_X * WORLD_Y * (2 * sizeof(double) +
+ sizeof(char *));
+ if (!empth_create(PP_UPDATE, update_wait, stacksize, 0,
+ "Update", "Updates the world", dp))
exit_nomem();
if (!empth_create(PP_SCHED, update_sched, 50 * 1024, 0,
exit_nomem();
if (!empth_create(PP_SCHED, update_sched, 50 * 1024, 0,
update_wait(void *unused)
{
struct player *p;
update_wait(void *unused)
{
struct player *p;
- int stacksize;
- struct player *dp;
+
+ player->proc = empth_self();
+ player->cnum = 0;
+ player->god = 1;
while (1) {
empth_sem_wait(update_sem);
while (1) {
empth_sem_wait(update_sem);
- /*
- * we rely on the fact that update's priority is the highest
- * in the land so it can finish before it yields.
- */
- dp = player_new(-1);
- if (!dp) {
- logerror("can't create dummy player for update");
- update_pending = 0;
- empth_rwlock_unlock(update_lock);
- continue;
- }
- stacksize = 100000 +
-/* finish_sects */ WORLD_X * WORLD_Y * (2 * sizeof(double) +
- sizeof(char *));
-
- empth_create(PP_UPDATE, update_main, stacksize, 0,
- "UpdateRun", "Updates the world", dp);
-
- while (update_pending)
- empth_yield(); /* FIXME cheesy! */
update_pending = 0;
empth_rwlock_unlock(update_lock);
}
update_pending = 0;
empth_rwlock_unlock(update_lock);
}