static int __init alsa_seq_oss_init(void) { int rc; if ((rc = register_device()) < 0) goto error; if ((rc = register_proc()) < 0) { unregister_device(); goto error; } if ((rc = snd_seq_oss_create_client()) < 0) { unregister_proc(); unregister_device(); goto error; } rc = snd_seq_driver_register(&seq_oss_synth_driver); if (rc < 0) { snd_seq_oss_delete_client(); unregister_proc(); unregister_device(); goto error; } /* success */ snd_seq_oss_synth_init(); error: return rc; }
static int __init alsa_seq_oss_init(void) { int rc; static struct snd_seq_dev_ops ops = { snd_seq_oss_synth_register, snd_seq_oss_synth_unregister, }; snd_seq_autoload_lock(); if ((rc = register_device()) < 0) goto error; if ((rc = register_proc()) < 0) { unregister_device(); goto error; } if ((rc = snd_seq_oss_create_client()) < 0) { unregister_proc(); unregister_device(); goto error; } if ((rc = snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OSS, &ops, sizeof(struct snd_seq_oss_reg))) < 0) { snd_seq_oss_delete_client(); unregister_proc(); unregister_device(); goto error; } /* success */ snd_seq_oss_synth_init(); error: snd_seq_autoload_unlock(); return rc; }
int main() { struct timeval t1, t2; printf("Input a number representing the number of timers for factorial: "); scanf("%d",&ROUND); printf("Input a number representing the rate of period over processing: "); scanf("%d",&PERIOD_PRO_RATIO); printf("Input a number representing the number of repeating jobs: "); scanf("%d",&JOB_NUM); // estimate the job time int comp_time = get_job_time(); int period = PERIOD_PRO_RATIO * comp_time; printf("cal job time: %d ms \n", comp_time); // register in the module int pid = register_proc(period, comp_time); printf("computation time: %d ms, period: %d ms \n", comp_time,period); // verify the process was admitted if (!verify(pid)) { printf("process %d was not admitted!\n", pid); exit(1); } yield(pid); // real-time loop int i; for (i=0; i<JOB_NUM; i++){ system("cat /proc/mp2/status"); gettimeofday(&t1,NULL); printf("Start Time of this job with ID %d : %d sec \n",pid,t1.tv_sec); do_job(); gettimeofday(&t2,NULL); printf("End Time of this job with ID %d : %d sec \n",pid,t2.tv_sec); yield(pid); } deregister(pid); // read the list of processes //system("cat /proc/mp2/status"); printf("Test application ends.\n"); return 0; }