Ejemplo n.º 1
0
/*
 * The medium thread tries to acquire a mutex, releases it once acquired and then 
 * receives from highest priority thread in scenario 1. It increments 2 counters 
 * on success, one for each operation.
 * It acquires a mutex at initialisation time and waits for any thread before
 * releasing the mutex in scenario 2. It increments 2 counters on success, 
 * one for each operation.
 */
void
mixed_pi_medium(int argc, char **argv)
{
    L4_ThreadId_t any_thread, tid;
    L4_MsgTag_t tag;
    int counter = 10000;

    while (!libs_ready) ;
    while (L4_IsNilThread(medium1_prio_thread)) ;
    tid = medium1_prio_thread;

    //printf("Middle thread %lx/%lx starts PI test\n", me, pi_main.raw);
    while (1) {
        // Initialisation
        if (scenario2) {
            //printf("Middle thread %lx/%lx acquires mutex for resource\n", me, pi_main.raw);
            okl4_libmutex_count_lock(resource_mutex);
            cnt_m1++;
        }
        //printf("(Initialisation) Medium thread %lx/%lx blocks open receiving\n", me, pi_main.raw);
        L4_Wait(&any_thread);
        //printf("(Initialisation) Medium thread %lx/%lx received from 0x%lx\n", me, pi_main.raw, any_thread.raw);
        L4_LoadMR(0, 0);
        L4_Send(tid);
        L4_Yield();
        /*** Start test ***/
        while (stop_spinning) ;
        wait_a_bit(counter);
        if (scenario1) {
            okl4_libmutex_count_lock(resource_mutex);
            cnt_m1++;
            wait_a_bit(counter);
        } else if (scenario2) {
            //printf("Middle thread %lx/%lx blocks open receiving\n", me, pi_main.raw);
            tag = L4_Wait(&any_thread);
            if (L4_IpcSucceeded(tag) && (any_thread.raw == low_prio_thread.raw))
                cnt_m2++;
            wait_a_bit(counter);
        }
        okl4_libmutex_count_unlock(resource_mutex);
        if (!flag1 && (counter < LIMIT)) {
            counter *= 2;
        }
        if (scenario1) {
            cnt_m2++;
            tag = L4_Receive(high_prio_thread);
            if (L4_IpcFailed(tag))
                cnt_m2--;
        }
        L4_Yield();
        tid = pi_main;
    }
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]){
	LinphoneCore *lc;
	LinphoneCoreVTable vtable={0};
	LinphoneSoundDaemon *lsd;
	LsdPlayer *p;

	linphone_core_enable_logs(stdout);
	lc=linphone_core_new(&vtable,NULL,NULL,NULL);
	lsd=linphone_sound_daemon_new (NULL,44100,1);

	linphone_core_use_sound_daemon(lc,lsd);

	/* start a play */
	p=linphone_sound_daemon_get_player(lsd);
	lsd_player_set_callback (p,play_finished);
	lsd_player_set_user_pointer (p,"share/hello8000.wav");
	lsd_player_play (p,"share/hello8000.wav");
	wait_a_bit (lc,2);

	/*start another one */
	p=linphone_sound_daemon_get_player(lsd);
	lsd_player_set_callback (p,play_finished);
	lsd_player_set_user_pointer (p,"share/hello16000.wav");
	lsd_player_enable_loop (p,TRUE);
	lsd_player_play (p,"share/hello16000.wav");

	/* after a few seconds decrease the volume */
	wait_a_bit (lc,3);
	lsd_player_set_gain (p,0.3);
	wait_a_bit(lc,5);

	/*now play some stereo music*/
	p=linphone_sound_daemon_get_player(lsd);
	lsd_player_set_callback (p,play_finished);
	lsd_player_set_user_pointer (p,"share/rings/rock.wav");
	lsd_player_play(p,"share/rings/rock.wav");
	wait_a_bit(lc,2);

	/*now play some stereo music at 22khz in order to test
	 stereo resampling */
	p=linphone_sound_daemon_get_player(lsd);
	lsd_player_set_callback (p,play_finished);
	lsd_player_set_user_pointer (p,"share/rings/bigben.wav");
	lsd_player_play(p,"share/rings/bigben.wav");
	wait_a_bit(lc,6);

	/* now place an outgoing call if sip address argument is given */
	if (argc>1){
		linphone_core_invite(lc,argv[1]);
		wait_a_bit(lc,10);
		linphone_core_terminate_call(lc,NULL);
	}
	linphone_core_use_sound_daemon(lc,NULL);
	linphone_sound_daemon_destroy(lsd);
	linphone_core_destroy(lc);
	
	return 0;
}
Ejemplo n.º 3
0
_CRTIMP void * __cdecl _realloc_crt(void *ptr, size_t size)
{
    unsigned long WaitTime = 0;
    void *pv;

Retry:
    pv = realloc(ptr, size);
    if (!pv && size && _maxwait > 0) {
        WaitTime = wait_a_bit(WaitTime);
        if (WaitTime != -1)
            goto Retry;
    }
    return pv;
}
Ejemplo n.º 4
0
_CRTIMP void * __cdecl _malloc_crt(size_t cb)
{
    unsigned long WaitTime = 0;
    void *pv;

Retry:
    pv = malloc(cb);
    if (!pv && _maxwait > 0) {
        WaitTime = wait_a_bit(WaitTime);
        if (WaitTime != -1)
            goto Retry;
    }
    return pv;
}
Ejemplo n.º 5
0
_CRTIMP void * __cdecl _calloc_crt(size_t count, size_t size)
{
    unsigned long WaitTime = 0;
    void *pv;

    extern void * __cdecl _calloc_impl (size_t, size_t, int *);

Retry:
    pv = _calloc_impl(count, size, NULL);
    if (!pv && _maxwait > 0) {
        WaitTime = wait_a_bit(WaitTime);
        if (WaitTime != -1)
            goto Retry;
    }
    return pv;
}
Ejemplo n.º 6
0
/*
 * The lowest priority thread acquires a mutex at initialisation time, releases
 * it the next it is run in scenario 1. It increments a counter on success.
 * It sends IPC to medium thread in scenario 2. It increments a counter on success.
 */
void
mixed_pi_low(int argc, char **argv)
{
    L4_ThreadId_t tid;
    L4_MsgTag_t tag;
    int counter = 10000;

    while (!libs_ready) ;
    while (L4_IsNilThread(medium3_prio_thread)) ;
    tid = medium3_prio_thread;

    //printf("Low thread %lx/%lx starts PI test\n", me, pi_main.raw);
    while (1) {
        // Initalisation
        if (scenario1) {
            //printf("Low thread %lx/%lx acquires mutex for resource\n", me, pi_main.raw);
            okl4_libmutex_count_lock(resource_mutex);
            cnt_l++;
        }
        //printf("(Initialisation) Low thread %lx/%lx blocks sending to Medium thread\n", me, pi_main.raw);
        L4_LoadMR(0, 0);
        L4_Send(tid);
        //printf("(Initialisation) Low thread %lx/%lx sent to Medium thread\n", me, pi_main.raw);
        L4_Yield();
        /*** Start test ***/
        while (stop_spinning) ;
        wait_a_bit(counter);
        if (!flag1 && (counter < LIMIT)) {
            counter *= 2;
        }
        if (scenario1) {
            okl4_libmutex_count_unlock(resource_mutex);
        } else if (scenario2) {
            cnt_l++;
            //printf("Low thread %lx/%lx blocks sending to Medium thread\n", me, pi_main.raw);
            L4_LoadMR(0, 0);
            tag = L4_Send(medium2_prio_thread);
            if (L4_IpcFailed(tag))
                cnt_l--;
        }
        L4_Yield();
        tid = medium2_prio_thread;
    }
}