Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18117
Modified Files: Tag: devel_0_37 d_soundfile.c Log Message: memory locking
Index: d_soundfile.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v retrieving revision 1.1.1.2.2.6 retrieving revision 1.1.1.2.2.7 diff -C2 -d -r1.1.1.2.2.6 -r1.1.1.2.2.7 *** d_soundfile.c 30 May 2004 17:18:07 -0000 1.1.1.2.2.6 --- d_soundfile.c 31 May 2004 12:02:21 -0000 1.1.1.2.2.7 *************** *** 886,889 **** --- 886,892 ---- #ifdef THREADED_SF #include <sched.h> + #ifdef _POSIX_MEMLOCK + #include <sys/mman.h> + #endif /* _POSIX_MEMLOCK */
static pthread_t sf_thread_id; /* id of soundfiler thread */ *************** *** 995,1004 **** { struct sched_param sf_param; ! sf_param.sched_priority=sched_get_priority_min(SCHED_FIFO);
if (sched_setscheduler(0,SCHED_FIFO,&sf_param) != -1) ! fprintf(stderr, "priority %d scheduling for soundfiler.\n", sf_param.sched_priority); ! while (1) { --- 998,1008 ---- { struct sched_param sf_param; ! sf_param.sched_priority=sched_get_priority_min(SCHED_FIFO)+1;
if (sched_setscheduler(0,SCHED_FIFO,&sf_param) != -1) ! fprintf(stderr, "priority %d scheduling for soundfiler.\n", sf_param.sched_priority); ! ! while (1) { *************** *** 1125,1129 **** pthread_mutex_unlock(&(soundfiler_queue->mutex));
! if (pthread_create(&sf_thread_id, NULL , (void *) soundfiler_thread,NULL) !=0) error("Couldn't create soundfiler thread"); --- 1129,1133 ---- pthread_mutex_unlock(&(soundfiler_queue->mutex));
! if (pthread_create(&sf_thread_id, NULL, (void *) soundfiler_thread,NULL) !=0) error("Couldn't create soundfiler thread"); *************** *** 1313,1317 **** --- 1317,1327 ---- for (i = 0; i < argc; i++) { + #ifdef _POSIX_MEMLOCK + munlockall(); + #endif nvecs[i]=getbytes (finalsize * sizeof(t_float)); + #ifdef _POSIX_MEMLOCK + mlockall(MCL_FUTURE); + #endif /* if we are out of memory, free it again and quit */ if (nvecs[i]==0) *************** *** 1328,1332 **** --- 1338,1348 ---- for (i = 0; i < argc; i++) { + #ifdef _POSIX_MEMLOCK + munlockall(); + #endif nvecs[i] = getbytes (vecsize[i] * sizeof(t_float)); + #ifdef _POSIX_MEMLOCK + mlockall(MCL_FUTURE); + #endif /* if we are out of memory, free it again and quit */ if (nvecs[i]==0) *************** *** 1340,1344 **** } } -
for (itemsread = 0; itemsread < finalsize; ) --- 1356,1359 ---- *************** *** 1401,1409 **** }
/* free the old arrays */ for (i = 0; i < argc; i++) freebytes(vecs[i], vecsize[i] * sizeof(t_float));
- fclose(fp); fd = -1; --- 1416,1424 ---- }
+ end: /* free the old arrays */ for (i = 0; i < argc; i++) freebytes(vecs[i], vecsize[i] * sizeof(t_float));
fclose(fp); fd = -1; *************** *** 1596,1609 ****
if (was > n) nvec = copybytes(x->x_array.a_vec, was * elemsize); else ! { ! nvec = getbytes(n * elemsize); ! memcpy (nvec, x->x_array.a_vec, was * elemsize); ! ! /* LATER should check t_resizebytes result */ ! memset(nvec + was*elemsize, ! 0, (n - was) * elemsize); ! } if (!nvec) { --- 1611,1638 ----
if (was > n) + { + #ifdef _POSIX_MEMLOCK + munlockall(); + #endif nvec = copybytes(x->x_array.a_vec, was * elemsize); + #ifdef _POSIX_MEMLOCK + mlockall(MCL_FUTURE); + #endif + } else ! { ! #ifdef _POSIX_MEMLOCK ! munlockall(); ! #endif ! nvec = getbytes(n * elemsize); ! #ifdef _POSIX_MEMLOCK ! mlockall(MCL_FUTURE); ! #endif ! memcpy (nvec, x->x_array.a_vec, was * elemsize); ! ! /* LATER should check t_resizebytes result */ ! memset(nvec + was*elemsize, ! 0, (n - was) * elemsize); ! } if (!nvec) {