reworked snooze to work in function of the newly added (and kernel exported) snooze_etc. Activated libroot counterpart(s).

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1723 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
lillo 2002-10-27 12:06:40 +00:00
parent 292e22f81d
commit a2117f0bc7
11 changed files with 28 additions and 20 deletions

View File

@ -26,7 +26,7 @@ int sys_getrlimit(int resource, struct rlimit * rlp);
int sys_setrlimit(int resource, const struct rlimit * rlp);
bigtime_t sys_system_time();
int sys_snooze(bigtime_t time);
status_t sys_snooze_until(bigtime_t time, int timebase);
/* sem functions */
sem_id sys_create_sem(int count, const char *name);

View File

@ -26,7 +26,7 @@ enum {
SYSCALL_READ_PATH_STAT,
SYSCALL_WRITE_PATH_STAT,
SYSCALL_SYSTEM_TIME,
SYSCALL_SNOOZE,
SYSCALL_SNOOZE_UNTIL,
SYSCALL_SEM_CREATE,
SYSCALL_SEM_DELETE,
SYSCALL_SEM_ACQUIRE, /* 20 */

View File

@ -112,7 +112,7 @@ main(int argc, char **argv)
}
printf("Done. Entering sleep mode...\n");
while (1) {
if (sys_snooze(1000000000L) == B_INTERRUPTED)
if (snooze(1000000000L) == B_INTERRUPTED)
// this never gets called as the syscall is always restarted
printf("sig_test (main): snooze was interrupted!\n");
}

View File

@ -18,7 +18,7 @@ static int32 test_thread(void *args)
{
int i = (int)args;
sys_snooze(1000000);
snooze(1000000);
for(;;) {
printf("%c", 'a' + i);
}
@ -74,7 +74,7 @@ int main(int argc, char **argv)
#endif
#if 0
for(;;) {
sys_snooze(100000);
snooze(100000);
printf("booyah!");
}
@ -82,7 +82,7 @@ int main(int argc, char **argv)
#endif
#if 0
printf("waiting 5 seconds\n");
sys_snooze(5000000);
snooze(5000000);
#endif
#if 0
fd = sys_open("/dev/net/rtl8139/0", "", STREAM_TYPE_DEVICE);
@ -154,7 +154,7 @@ int main(int argc, char **argv)
resume_thread(tids[i]);
}
sys_snooze(5000000);
snooze(5000000);
sys_kill_team(sys_get_current_team_id());
/*
sys_snooze(3000000);
@ -196,7 +196,7 @@ int main(int argc, char **argv)
printf("writing to the speaker\n");
data = 3;
sys_write(fd, &data, 0, 1);
sys_snooze(1000000);
snooze(1000000);
data = 0;
sys_write(fd, &data, 0, 1);
sys_close(fd);

View File

@ -102,7 +102,7 @@ int main(int argc, char **argv)
resume_thread(t[1]);
resume_thread(t[2]);
sys_snooze(100000);
snooze(100000);
sys_wait_on_thread(t[0], NULL);
sys_wait_on_thread(t[1], NULL);
@ -115,7 +115,7 @@ int main(int argc, char **argv)
printf("sending");
send_data(t[0], i, comm_test[i], strlen(comm_test[i]) + 1);
// Give time to the commthread to display info
sys_snooze(10000);
snooze(10000);
}
sys_wait_on_thread(t[0], NULL);

View File

@ -175,8 +175,8 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re
case SYSCALL_SYSTEM_TIME:
*call_ret = system_time();
break;
case SYSCALL_SNOOZE:
*call_ret = snooze((bigtime_t)INT32TOINT64(arg0, arg1));
case SYSCALL_SNOOZE_UNTIL:
*call_ret = snooze_etc((bigtime_t)INT32TOINT64(arg0, arg1), (int)arg2, B_CAN_INTERRUPT);
break;
case SYSCALL_SEM_CREATE:
*call_ret = user_create_sem((int)arg0, (const char *)arg1);

View File

@ -884,10 +884,20 @@ thread_init_percpu(int cpu_num)
}
// This snooze is for internal kernel use only; doesn't interrupt on signals.
status_t
snooze(bigtime_t timeout)
{
return acquire_sem_etc(snooze_sem, 1, B_TIMEOUT | B_CAN_INTERRUPT, timeout);
return acquire_sem_etc(snooze_sem, 1, B_RELATIVE_TIMEOUT, timeout);
}
status_t
snooze_etc(bigtime_t timeout, int timebase, uint32 flags)
{
if (timebase != B_SYSTEM_TIMEBASE)
return B_BAD_VALUE;
return acquire_sem_etc(snooze_sem, 1, B_ABSOLUTE_TIMEOUT | flags, timeout);
}

View File

@ -96,7 +96,7 @@ SYSCALL4(sys_spawn_thread, 35)
SYSCALL1(sys_kill_thread, 36)
SYSCALL1(sys_suspend_thread, 37)
SYSCALL1(sys_resume_thread, 38)
SYSCALL2(sys_snooze, 17)
SYSCALL3(sys_snooze_until, 17)
SYSCALL4(send_data, 94)
SYSCALL3(receive_data, 95)
SYSCALL1(has_data, 96)

View File

@ -149,16 +149,14 @@ has_data(thread_id thread)
status_t
snooze(bigtime_t microseconds)
{
// ToDo: snooze()
return B_ERROR;
return sys_snooze_until(system_time() + microseconds, B_SYSTEM_TIMEBASE);
}
status_t
snooze_until(bigtime_t time, int timeBase)
{
// ToDo: snooze_until()
return B_ERROR;
return sys_snooze_until(time, timeBase);
}

View File

@ -20,7 +20,7 @@ sleep(unsigned seconds)
usecs= 1000000;
usecs*= (bigtime_t) seconds;
err= sys_snooze(usecs);
err= sys_snooze_until(start + usecs, B_SYSTEM_TIMEBASE);
retval= 0;
if(err) {

View File

@ -10,5 +10,5 @@
int
usleep(unsigned useconds)
{
return sys_snooze((bigtime_t)(useconds));
return sys_snooze_until(sys_system_time() + (bigtime_t)(useconds), B_SYSTEM_TIMEBASE);
}