Removed all usage of TerminateThread()/thread_kill(), thread_wait() is used instead now.
This commit is contained in:
@@ -921,7 +921,8 @@ pc_close(thread_t *ptr)
|
||||
|
||||
/* Terminate the main thread. */
|
||||
if (ptr != NULL) {
|
||||
thread_kill(ptr);
|
||||
is_quit = 1;
|
||||
thread_wait(ptr, -1);
|
||||
|
||||
/* Wait some more. */
|
||||
plat_delay_ms(200);
|
||||
|
||||
@@ -150,7 +150,6 @@ typedef void event_t;
|
||||
typedef void mutex_t;
|
||||
|
||||
extern thread_t *thread_create(void (*thread_func)(void *param), void *param);
|
||||
extern void thread_kill(thread_t *arg);
|
||||
extern int thread_wait(thread_t *arg, int timeout);
|
||||
extern event_t *thread_create_event(void);
|
||||
extern void thread_set_event(event_t *arg);
|
||||
|
||||
@@ -500,8 +500,9 @@ typedef struct voodoo_t
|
||||
void *codegen_data;
|
||||
|
||||
struct voodoo_set_t *set;
|
||||
|
||||
|
||||
|
||||
uint8_t fifo_thread_run, render_thread_run[4];
|
||||
|
||||
uint8_t *vram, *changedvram;
|
||||
|
||||
void *p;
|
||||
|
||||
@@ -253,6 +253,7 @@ typedef struct mach64_t
|
||||
|
||||
int overlay_v_acc;
|
||||
|
||||
uint8_t thread_run;
|
||||
void *i2c, *ddc;
|
||||
} mach64_t;
|
||||
|
||||
@@ -931,7 +932,7 @@ static void fifo_thread(void *param)
|
||||
{
|
||||
mach64_t *mach64 = (mach64_t *)param;
|
||||
|
||||
while (1)
|
||||
while (mach64->thread_run)
|
||||
{
|
||||
thread_set_event(mach64->fifo_not_full_event);
|
||||
thread_wait_event(mach64->wake_fifo_thread, -1);
|
||||
@@ -3364,6 +3365,7 @@ static void *mach64_common_init(const device_t *info)
|
||||
|
||||
mach64->wake_fifo_thread = thread_create_event();
|
||||
mach64->fifo_not_full_event = thread_create_event();
|
||||
mach64->thread_run = 1;
|
||||
mach64->fifo_thread = thread_create(fifo_thread, mach64);
|
||||
|
||||
mach64->i2c = i2c_gpio_init("ddc_ati_mach64");
|
||||
@@ -3455,7 +3457,8 @@ void mach64_close(void *p)
|
||||
|
||||
svga_close(&mach64->svga);
|
||||
|
||||
thread_kill(mach64->fifo_thread);
|
||||
mach64->thread_run = 0;
|
||||
thread_wait(mach64->fifo_thread, -1);
|
||||
thread_destroy_event(mach64->wake_fifo_thread);
|
||||
thread_destroy_event(mach64->fifo_not_full_event);
|
||||
|
||||
|
||||
@@ -502,6 +502,8 @@ typedef struct mystique_t
|
||||
mutex_t *lock;
|
||||
} dma;
|
||||
|
||||
uint8_t thread_run;
|
||||
|
||||
void *i2c, *i2c_ddc, *ddc;
|
||||
} mystique_t;
|
||||
|
||||
@@ -2354,7 +2356,7 @@ fifo_thread(void *p)
|
||||
{
|
||||
mystique_t *mystique = (mystique_t *)p;
|
||||
|
||||
while (1) {
|
||||
while (mystique->thread_run) {
|
||||
thread_set_event(mystique->fifo_not_full_event);
|
||||
thread_wait_event(mystique->wake_fifo_thread, -1);
|
||||
thread_reset_event(mystique->wake_fifo_thread);
|
||||
@@ -5008,6 +5010,7 @@ mystique_init(const device_t *info)
|
||||
|
||||
mystique->wake_fifo_thread = thread_create_event();
|
||||
mystique->fifo_not_full_event = thread_create_event();
|
||||
mystique->thread_run = 1;
|
||||
mystique->fifo_thread = thread_create(fifo_thread, mystique);
|
||||
mystique->dma.lock = thread_create_mutex();
|
||||
|
||||
@@ -5031,7 +5034,8 @@ mystique_close(void *p)
|
||||
{
|
||||
mystique_t *mystique = (mystique_t *)p;
|
||||
|
||||
thread_kill(mystique->fifo_thread);
|
||||
mystique->thread_run = 0;
|
||||
thread_wait(mystique->fifo_thread, -1);
|
||||
thread_destroy_event(mystique->wake_fifo_thread);
|
||||
thread_destroy_event(mystique->fifo_not_full_event);
|
||||
thread_close_mutex(mystique->dma.lock);
|
||||
|
||||
@@ -319,7 +319,7 @@ typedef struct s3_t
|
||||
int enable_8514;
|
||||
volatile int busy, force_busy;
|
||||
|
||||
uint8_t serialport;
|
||||
uint8_t thread_run, serialport;
|
||||
void *i2c, *ddc;
|
||||
} s3_t;
|
||||
|
||||
@@ -1509,7 +1509,7 @@ fifo_thread(void *param)
|
||||
{
|
||||
s3_t *s3 = (s3_t *)param;
|
||||
|
||||
while (1)
|
||||
while (s3->thread_run)
|
||||
{
|
||||
thread_set_event(s3->fifo_not_full_event);
|
||||
thread_wait_event(s3->wake_fifo_thread, -1);
|
||||
@@ -6213,6 +6213,7 @@ static void *s3_init(const device_t *info)
|
||||
|
||||
s3->wake_fifo_thread = thread_create_event();
|
||||
s3->fifo_not_full_event = thread_create_event();
|
||||
s3->thread_run = 1;
|
||||
s3->fifo_thread = thread_create(fifo_thread, s3);
|
||||
|
||||
return s3;
|
||||
@@ -6319,7 +6320,8 @@ static void s3_close(void *p)
|
||||
|
||||
svga_close(&s3->svga);
|
||||
|
||||
thread_kill(s3->fifo_thread);
|
||||
s3->thread_run = 0;
|
||||
thread_wait(s3->fifo_thread, -1);
|
||||
thread_destroy_event(s3->wake_fifo_thread);
|
||||
thread_destroy_event(s3->fifo_not_full_event);
|
||||
|
||||
|
||||
@@ -288,6 +288,8 @@ typedef struct virge_t
|
||||
|
||||
uint8_t subsys_stat, subsys_cntl, advfunc_cntl;
|
||||
|
||||
uint8_t render_thread_run, fifo_thread_run;
|
||||
|
||||
uint8_t serialport;
|
||||
|
||||
void *i2c, *ddc;
|
||||
@@ -1122,7 +1124,7 @@ static void fifo_thread(void *param)
|
||||
{
|
||||
virge_t *virge = (virge_t *)param;
|
||||
|
||||
while (1)
|
||||
while (virge->fifo_thread_run)
|
||||
{
|
||||
thread_set_event(virge->fifo_not_full_event);
|
||||
thread_wait_event(virge->wake_fifo_thread, -1);
|
||||
@@ -3235,7 +3237,7 @@ static void render_thread(void *param)
|
||||
{
|
||||
virge_t *virge = (virge_t *)param;
|
||||
|
||||
while (1)
|
||||
while (virge->render_thread_run)
|
||||
{
|
||||
thread_wait_event(virge->wake_render_thread, -1);
|
||||
thread_reset_event(virge->wake_render_thread);
|
||||
@@ -3897,10 +3899,12 @@ static void *s3_virge_init(const device_t *info)
|
||||
virge->wake_render_thread = thread_create_event();
|
||||
virge->wake_main_thread = thread_create_event();
|
||||
virge->not_full_event = thread_create_event();
|
||||
virge->render_thread_run = 1;
|
||||
virge->render_thread = thread_create(render_thread, virge);
|
||||
|
||||
virge->wake_fifo_thread = thread_create_event();
|
||||
virge->fifo_not_full_event = thread_create_event();
|
||||
virge->fifo_thread_run = 1;
|
||||
virge->fifo_thread = thread_create(fifo_thread, virge);
|
||||
|
||||
virge->i2c = i2c_gpio_init("ddc_s3_virge");
|
||||
@@ -3915,12 +3919,14 @@ static void s3_virge_close(void *p)
|
||||
{
|
||||
virge_t *virge = (virge_t *)p;
|
||||
|
||||
thread_kill(virge->render_thread);
|
||||
virge->render_thread_run = 0;
|
||||
thread_wait(virge->render_thread, -1);
|
||||
thread_destroy_event(virge->not_full_event);
|
||||
thread_destroy_event(virge->wake_main_thread);
|
||||
thread_destroy_event(virge->wake_render_thread);
|
||||
|
||||
thread_kill(virge->fifo_thread);
|
||||
virge->fifo_thread_run = 0;
|
||||
thread_wait(virge->fifo_thread, -1);
|
||||
thread_destroy_event(virge->wake_fifo_thread);
|
||||
thread_destroy_event(virge->fifo_not_full_event);
|
||||
|
||||
|
||||
@@ -976,12 +976,18 @@ void *voodoo_card_init()
|
||||
voodoo->render_not_full_event[1] = thread_create_event();
|
||||
voodoo->render_not_full_event[2] = thread_create_event();
|
||||
voodoo->render_not_full_event[3] = thread_create_event();
|
||||
voodoo->fifo_thread_run = 1;
|
||||
voodoo->fifo_thread = thread_create(voodoo_fifo_thread, voodoo);
|
||||
voodoo->render_thread_run[0] = 1;
|
||||
voodoo->render_thread[0] = thread_create(voodoo_render_thread_1, voodoo);
|
||||
if (voodoo->render_threads >= 2)
|
||||
if (voodoo->render_threads >= 2) {
|
||||
voodoo->render_thread_run[1] = 1;
|
||||
voodoo->render_thread[1] = thread_create(voodoo_render_thread_2, voodoo);
|
||||
}
|
||||
if (voodoo->render_threads == 4) {
|
||||
voodoo->render_thread_run[2] = 1;
|
||||
voodoo->render_thread[2] = thread_create(voodoo_render_thread_3, voodoo);
|
||||
voodoo->render_thread_run[3] = 1;
|
||||
voodoo->render_thread[3] = thread_create(voodoo_render_thread_4, voodoo);
|
||||
}
|
||||
voodoo->swap_mutex = thread_create_mutex();
|
||||
@@ -1094,12 +1100,18 @@ void *voodoo_2d3d_card_init(int type)
|
||||
voodoo->render_not_full_event[1] = thread_create_event();
|
||||
voodoo->render_not_full_event[2] = thread_create_event();
|
||||
voodoo->render_not_full_event[3] = thread_create_event();
|
||||
voodoo->fifo_thread_run = 1;
|
||||
voodoo->fifo_thread = thread_create(voodoo_fifo_thread, voodoo);
|
||||
voodoo->render_thread_run[0] = 1;
|
||||
voodoo->render_thread[0] = thread_create(voodoo_render_thread_1, voodoo);
|
||||
if (voodoo->render_threads >= 2)
|
||||
if (voodoo->render_threads >= 2) {
|
||||
voodoo->render_thread_run[1] = 1;
|
||||
voodoo->render_thread[1] = thread_create(voodoo_render_thread_2, voodoo);
|
||||
}
|
||||
if (voodoo->render_threads == 4) {
|
||||
voodoo->render_thread_run[2] = 1;
|
||||
voodoo->render_thread[2] = thread_create(voodoo_render_thread_3, voodoo);
|
||||
voodoo->render_thread_run[3] = 1;
|
||||
voodoo->render_thread[3] = thread_create(voodoo_render_thread_4, voodoo);
|
||||
}
|
||||
voodoo->swap_mutex = thread_create_mutex();
|
||||
@@ -1243,13 +1255,19 @@ void voodoo_card_close(voodoo_t *voodoo)
|
||||
#endif */
|
||||
|
||||
|
||||
thread_kill(voodoo->fifo_thread);
|
||||
thread_kill(voodoo->render_thread[0]);
|
||||
if (voodoo->render_threads >= 2)
|
||||
thread_kill(voodoo->render_thread[1]);
|
||||
voodoo->fifo_thread_run = 0;
|
||||
thread_wait(voodoo->fifo_thread, -1);
|
||||
voodoo->render_thread_run[0] = 0;
|
||||
thread_wait(voodoo->render_thread[0], -1);
|
||||
if (voodoo->render_threads >= 2) {
|
||||
voodoo->render_thread_run[1] = 0;
|
||||
thread_wait(voodoo->render_thread[1], -1);
|
||||
}
|
||||
if (voodoo->render_threads == 4) {
|
||||
thread_kill(voodoo->render_thread[2]);
|
||||
thread_kill(voodoo->render_thread[3]);
|
||||
voodoo->render_thread_run[2] = 0;
|
||||
thread_wait(voodoo->render_thread[2], -1);
|
||||
voodoo->render_thread_run[3] = 0;
|
||||
thread_wait(voodoo->render_thread[3], -1);
|
||||
}
|
||||
thread_destroy_event(voodoo->fifo_not_full_event);
|
||||
thread_destroy_event(voodoo->wake_main_thread);
|
||||
|
||||
@@ -204,7 +204,7 @@ void voodoo_fifo_thread(void *param)
|
||||
{
|
||||
voodoo_t *voodoo = (voodoo_t *)param;
|
||||
|
||||
while (1)
|
||||
while (voodoo->fifo_thread_run)
|
||||
{
|
||||
thread_set_event(voodoo->fifo_not_full_event);
|
||||
thread_wait_event(voodoo->wake_fifo_thread, -1);
|
||||
|
||||
@@ -1605,7 +1605,7 @@ static void render_thread(void *param, int odd_even)
|
||||
{
|
||||
voodoo_t *voodoo = (voodoo_t *)param;
|
||||
|
||||
while (1)
|
||||
while (voodoo->render_thread_run[odd_even])
|
||||
{
|
||||
thread_set_event(voodoo->render_not_full_event[odd_even]);
|
||||
thread_wait_event(voodoo->wake_render_thread[odd_even], -1);
|
||||
|
||||
@@ -113,6 +113,7 @@ int video_graytype = 0;
|
||||
static int vid_type;
|
||||
static const video_timings_t *vid_timings;
|
||||
static uint32_t cga_2_table[16];
|
||||
static uint8_t thread_run = 0;
|
||||
|
||||
|
||||
PALETTE cgapal = {
|
||||
@@ -430,7 +431,7 @@ void blit_thread(void *param)
|
||||
{
|
||||
int yy;
|
||||
|
||||
while (1) {
|
||||
while (thread_run) {
|
||||
thread_wait_event(blit_data.wake_blit_thread, -1);
|
||||
thread_reset_event(blit_data.wake_blit_thread);
|
||||
MTR_BEGIN("video", "blit_thread");
|
||||
@@ -880,6 +881,7 @@ video_init(void)
|
||||
blit_data.wake_blit_thread = thread_create_event();
|
||||
blit_data.blit_complete = thread_create_event();
|
||||
blit_data.buffer_not_in_use = thread_create_event();
|
||||
thread_run = 1;
|
||||
blit_data.blit_thread = thread_create(blit_thread, NULL);
|
||||
}
|
||||
|
||||
@@ -887,7 +889,8 @@ video_init(void)
|
||||
void
|
||||
video_close(void)
|
||||
{
|
||||
thread_kill(blit_data.blit_thread);
|
||||
thread_run = 0;
|
||||
thread_wait(blit_data.blit_thread, -1);
|
||||
thread_destroy_event(blit_data.buffer_not_in_use);
|
||||
thread_destroy_event(blit_data.blit_complete);
|
||||
thread_destroy_event(blit_data.wake_blit_thread);
|
||||
|
||||
@@ -44,15 +44,6 @@ thread_create(void (*func)(void *param), void *param)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
thread_kill(void *arg)
|
||||
{
|
||||
if (arg == NULL) return;
|
||||
|
||||
TerminateThread(arg, 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
thread_wait(thread_t *arg, int timeout)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user