コード例 #1
0
ファイル: NdbMem.c プロジェクト: 4T-Shirt/mysql
int NdbMem_MemUnlockAll(){
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
  return munlockall();
#else
  return -1;
#endif
}
コード例 #2
0
ファイル: Resources.cpp プロジェクト: HSOFEUP/dune
    void
    Resources::unlockMemory(void)
    {
#if defined(DUNE_SYS_HAS_MUNLOCKALL)
      munlockall();
#endif
    }
コード例 #3
0
ファイル: RealtimeSync_c_intf.cpp プロジェクト: lonnell/trick
extern "C" int real_time_lock_memory(int yes_no) {
    /* lock or unlock memory based on yes_no parameter */
    int ret = 0 ;
#if __linux
    if ( yes_no ) {
        if ((ret = mlockall(MCL_CURRENT | MCL_FUTURE)) != 0 ) {
            perror("Error locking memory.");
            message_publish(MSG_ERROR, "Error %d when requesting memory lock.\n", errno);
        } else {
            message_publish(MSG_INFO, "Sim locked memory\n");
        }
    } else {
        if ( (ret = munlockall()) != 0 ) {
            perror("Error unlocking memory.");
            message_publish(MSG_ERROR, "Error %d when requesting memory unlock.\n", errno);
        } else {
            message_publish(MSG_INFO, "Sim unlocked memory\n");
        }

    }
#endif
#if __APPLE__
    (void)yes_no ;
    message_publish(MSG_WARNING, "Warning: Trick on Darwin does not yet support memory locking.\n");
#endif
    return ret ;
}
コード例 #4
0
ファイル: 5-1.c プロジェクト: SummerSnail2014/haiku
int main(){
	int result;
	long memlock;

	memlock = sysconf(_SC_MEMLOCK);
	if(errno){
		perror("An errno occurs when calling sysconf().\n");
		return PTS_UNRESOLVED;
	}

	result = munlockall();
	
	if( (result == 0 && memlock > 0) || (result == -1 && memlock <=0) ){
		printf("Test PASSED\n");
		return PTS_PASS;
	} else if(errno == EPERM){
		printf("You don't have permission to unlock your address space.\nTry to rerun this test as root.\n");
		return PTS_UNRESOLVED;
	} else {
		printf("munlockall() returns %i instead of zero.\n",
		       result);
		return PTS_FAIL;
	}

}
コード例 #5
0
ファイル: munlockall02.c プロジェクト: 1587/ltp
int main(int ac, char **av)
{
	int lc;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	/* check looping state */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		TEST(munlockall());
		/* check return code */
		if ((TEST_RETURN == -1) && (TEST_ERRNO == EPERM)) {
			tst_resm(TPASS, "munlockall() failed"
				 " as expected for non-superuser" ":GOT EPERM");
		} else {
			tst_resm(TCONF, "munlockall() failed to produce "
				 "expected errno :%d Got : %d, %s. ***Some distros, such as Red Hat Enterprise Linux, support non-superuser munlockall calls.***",
				 EPERM, TEST_ERRNO, strerror(TEST_ERRNO));

		}
	}

	/* cleanup and exit */
	cleanup();
	tst_exit();

}
コード例 #6
0
ファイル: fusexmp1.c プロジェクト: nakuldhotre/dedupcache
void
xmp_destroy ()
{
/*HASH_TABLE_MEMORY_CACHE *temp2;
HASH_TABLE_INODE_N_BLOCK *temp1;
fprintf(stderr,"Calling destroy..\n");
 fprintf(stderr, " mem_add = %lf\n mem_find = %lf\nbinode_add = %lf\ninode_find = %lf\n",
          mem_add,mem_find,binode_add,binode_find);

  while(block_inode)
         {
        temp1=block_inode->hh.next;
        free(block_inode);
        block_inode=temp1;
        }

  while(memory)
 {
        temp2=memory->hh.next;
        free(memory);
        memory=temp2;
 }

 */
  munlockall();
  fprintf (stderr, "\ncase1=%d\n", case1);
  fprintf (stderr, "\ncase2=%d\n", case2);
  fprintf (stderr, "\ncase3=%d\n", case3);
  fprintf (stderr, "\ncase4=%d\n", case4);
}
コード例 #7
0
ファイル: munlockall01.c プロジェクト: MohdVara/ltp
int main(int ac, char **av)
{
	int lc;
	const char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	}

	setup();

	/* check looping state */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		TEST(munlockall());

		/* check return code */
		if (TEST_RETURN == -1) {
			tst_resm(TFAIL | TTERRNO, "munlockall() Failed with"
				 " return=%ld", TEST_RETURN);
		} else {
			tst_resm(TPASS, "munlockall() passed with"
				 " return=%ld ", TEST_RETURN);

		}
	}

	/* cleanup and exit */
	cleanup();
	tst_exit();

}
コード例 #8
0
ファイル: memlock.c プロジェクト: JabirTech/Source
int memlock(int argc, char *argv[])
{
	int e = 0;

	/* Is memory locking configured?
	 */
	errno = 0;
	if (sysconf(_SC_MEMLOCK) == -1) {
		if (errno != 0) {
			/* This isn't valid - may be a standard violation
			 */
			quit("(should not happen) sysconf(_SC_MEMLOCK)");
		}
		else {
			fprintf(stderr,
			"Memory locking is not supported in this environment.\n");
			e = -1;
		}
	}

	/* Lock yourself in memory:
	 */
	if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
		perror("mlockall(MCL_CURRENT | MCL_FUTURE)");
		e = errno;
	}
	else if (munlockall() == -1) {
		perror("munlockall");
		e = errno;
	}

	return e;
}
コード例 #9
0
ファイル: Resources.cpp プロジェクト: Aero348/dune
    void
    Resources::unlockMemory(void)
    {
#if defined(DUNE_SYS_HAS_SYS_MMAN_H)
      munlockall();
#endif
    }
コード例 #10
0
ファイル: pss-vect.c プロジェクト: Rupan/kep
int main(int argc, char **argv) {
  int ret;
  rsa_t rsa;
  uint32_t mc, vf;
  datum_t em, m;
  uint8_t EM[256];

  mlockall(MCL_CURRENT|MCL_FUTURE);

  rsa_init(&rsa);
  mc = vf = 0;
  em.data = (uint8_t *)EM;
  em.size = (uint32_t)sizeof(EM);

/*
generate these with gentests.pl
NOTE: in some cases, the RSA signing operation will produce a signature which
is 1 or more bytes less in length than N.  In these cases, it must be padded
on the left with zeros.
*/
#include "tests.c"

  rsa_free(&rsa);

  munlockall();

  printf("\nTest run completed with %d miscompares and %d verification failures.\n\n", mc, vf);

  return 0;
}
コード例 #11
0
ファイル: fosi_internal.cpp プロジェクト: fengzhuye/rtt
 INTERNAL_QUAL int rtos_task_delete_main(RTOS_TASK* main_task)
 {
     //rt_task_delete( &(main_task->xenotask) );
     free (main_task->name);
     main_task->name = NULL;
     munlockall();
     return 0;
 }
コード例 #12
0
ファイル: server.c プロジェクト: kekyo/xpilot-ng
static int plock(int op)
{
#if defined(MCL_CURRENT) && defined(MCL_FUTURE)
    return op ? mlockall(MCL_CURRENT | MCL_FUTURE) : munlockall();
#else
    return -1;
#endif
}
コード例 #13
0
 INTERNAL_QUAL int rtos_task_delete_main(RTOS_TASK* main_task)
 {
     // we don't stop the timer
     //stop_rt_timer();
     rt_task_delete(main_task->rtaitask);
     free(main_task->name);
     munlockall();
     return 0;
 }
コード例 #14
0
ファイル: angrymlocker.c プロジェクト: stiletto/angrymlocker
// Called when the library is unloaded and before dlclose()
// returns
void my_unload(void)
{
    int res = munlockall();
    if (debug_enabled) {
	if (!res)
	    fprintf(stderr,"munlock()'ed entire process's address space.\n");
        else
	    perror("munlockall()");
    }
}
コード例 #15
0
ファイル: utils.c プロジェクト: murali-marimekala/cryptsetup
int crypt_memlock_dec(struct crypt_device *ctx)
{
	if (_memlock_count && (!--_memlock_count)) {
		log_dbg("Unlocking memory.");
		if (munlockall() == -1)
			log_err(ctx, _("Cannot unlock memory."));
		if (setpriority(PRIO_PROCESS, 0, _priority))
			log_dbg("setpriority %d failed: %s", _priority, strerror(errno));
	}
	return _memlock_count ? 1 : 0;
}
コード例 #16
0
ファイル: coordinator.cpp プロジェクト: semajrolyat/tas
//-----------------------------------------------------------------------------
void shutdown( void ) {
  // unlock memory.  do before any other shutdown operations
  munlockall();

  printf( "shutting down\n" );

  // send notifications to clients

  msgbuffer.close();
  close_pipes();
}
コード例 #17
0
ファイル: memlock.c プロジェクト: ajinkya93/netbsd-src
static void _unlock_mem(void)
{
#ifdef MCL_CURRENT
	if (munlockall())
		log_sys_error("munlockall", "");
	else
		log_very_verbose("Unlocking memory");
#endif
	_release_memory();
	if (setpriority(PRIO_PROCESS, 0, _priority))
		log_error("setpriority %u failed: %s", _priority,
			  strerror(errno));
}
コード例 #18
0
ファイル: mlock2-tests.c プロジェクト: raoy1990/linux
static int test_mlockall(int (test_function)(bool call_mlock))
{
	int ret = 1;

	if (mlockall(MCL_CURRENT | MCL_ONFAULT | MCL_FUTURE)) {
		perror("mlockall");
		return ret;
	}

	ret = test_function(false);
	munlockall();
	return ret;
}
コード例 #19
0
ファイル: mlock.c プロジェクト: glandium/rr
int main(void) {
  size_t page_size = sysconf(_SC_PAGESIZE);
  void* p = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
                 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  test_assert(p != MAP_FAILED);

  test_assert(0 == mlock(p, page_size) || errno == ENOMEM || errno == EPERM);
  test_assert(0 == munlock(p, page_size));
  test_assert(0 == mlockall(MCL_CURRENT) || errno == ENOMEM || errno == EPERM);
  test_assert(0 == munlockall());

  atomic_puts("EXIT-SUCCESS");
  return 0;
}
コード例 #20
0
ファイル: os_process.c プロジェクト: diorahman/opensplice
/** \brief  re-enable paging for calling process.
 *
 *  Enables paging for all pages mapped into the address space ofi
 *  the calling process.
 */
os_result
os_procMUnlockAll(void)
{
    int r;
    os_result result;

    r = munlockall();
    if (r == 0) {
        result = os_resultSuccess;
    } else {
        result = os_resultFail;
    }
    return result;
}
コード例 #21
0
ファイル: raid6check.c プロジェクト: brain0/mdadm
int unlock_all_stripes(struct mdinfo *info, sighandler_t *sig) {
	int rv;
	rv = sysfs_set_num(info, NULL, "suspend_lo", 0x7FFFFFFFFFFFFFFFULL);
	rv |= sysfs_set_num(info, NULL, "suspend_hi", 0);
	rv |= sysfs_set_num(info, NULL, "suspend_lo", 0);

	signal(SIGQUIT, sig[2]);
	signal(SIGINT, sig[1]);
	signal(SIGTERM, sig[0]);

	if(munlockall() != 0)
		return 3;
	return rv * 256;
}
コード例 #22
0
static void CacheDestroy(ENGINE_HANDLE* handle, const bool force)
{
	sem_wait(readSem);
	sem_wait(writeSem);
	ReleaseBitArray();
	ReleaseMemoryTable();
	ReleaseDataRegion();
	free(handle);
	munlockall();
	muntrace();
	free(handle);
	sem_post(readSem);
	sem_post(writeSem);
}
コード例 #23
0
ファイル: mlockall.c プロジェクト: ikravets/tests-scribe
int main(int argc, char **argv)
{
	int i;
	pthread_t tha;

	mlockall(MCL_CURRENT);
	pthread_create(&tha, NULL, worker, NULL);
	for (i = 0; i < SIZE; i++) {
		printf("value: %d\n", mem[i]);
		nanosleep(&ts, NULL);
	}
	pthread_join(tha,NULL);
	munlockall();
	
	return 0;
}
コード例 #24
0
ファイル: wfa_sock.c プロジェクト: freshcoder/TDLS
/*
 * wfaSetProcPriority():
 * With the linux 2.6 kernel, it allows an application process dynamically 
 * adjust its running priority level. In order to achieve higher control of 
 * packet sending/receiving and timer response, it is helpful to raise the 
 * process priority level over others and lower it back once it finishes. 
 * 
 * This is purely used for performance tuning purpose and not required to
 * port if it is not needed.
 */
int wfaSetProcPriority(int set)
{
    int maxprio, currprio;
    struct sched_param schp;

    wMEMSET(&schp, 0, sizeof(schp));
    sched_getparam(0, &schp);

    currprio = schp.sched_priority;

    if(set != 0)
    {
        if(geteuid() == 0)
        {
           maxprio = sched_get_priority_max(SCHED_FIFO);
           if(maxprio == -1)
           {
              return WFA_FAILURE;
           }

           schp.sched_priority = maxprio;
           if(sched_setscheduler(0, SCHED_FIFO, &schp) != 0)
           {
           }
        }
       
        if(mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
        {

        }
    } 
    else
    {
        if(geteuid() == 0)
        {
           schp.sched_priority = 0;
           if(sched_setscheduler(0, SCHED_OTHER, &schp) != 0)
           {
           }
        }
       
        munlockall();
    }

    return currprio;
}
コード例 #25
0
ファイル: 5-1.c プロジェクト: SummerSnail2014/haiku
int main(){
	int result;
	
	result = munlockall();
	
	if(result == 0){
		printf("Test PASSED\n");
		return PTS_PASS;
	} else if(errno == EPERM){
		printf("You don't have permission to unlock your address space.\nTry to rerun this test as root.\n");
		return PTS_UNRESOLVED;
	} else {
		printf("munlockall() returns %i instead of zero.\n",
		       result);
		return PTS_FAIL;
	}

}
コード例 #26
0
void OneShotLatencyMeasurer::measure()
{
	if(lockMemory)
	{
		if(mlockall(MCL_CURRENT|MCL_FUTURE) != 0)
		{
			Logger::ERROR("Couldn't lock memory! Aborting...");
			exit(1);
		}
	}
	measureOneshotTimerLatencies();
	if(lockMemory)
	{
		munlockall();
	}
	latencyData->analyzeData();
	reportedLatencyData->analyzeData();
	differenceData->analyzeData();
}
コード例 #27
0
ファイル: munlockall02.c プロジェクト: CSU-GH/okl4_3.0
int main(int ac, char **av)
{
	int lc;		/* loop counter */
	char *msg;	/* message returned from parse_opts */

	if ((msg = parse_opts(ac,av,(option_t *)NULL, NULL)) != (char *) NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
		tst_exit();
	}

	/* perform global setup for test */
	setup();

	/* check looping state */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping. */
		Tst_count = 0;
		
		TEST(munlockall());
		
                TEST_ERROR_LOG(TEST_ERRNO); 
		/* check return code */
		if ((TEST_RETURN == -1) && (TEST_ERRNO == EPERM)){
				tst_resm(TPASS, "munlockall() failed"
				" as expected for non-superuser"
				":GOT EPERM");			
		} else {
	  		tst_resm(TCONF, "munlockall() failed to produce "	
					"expected errno :%d Got : %d, %s. ***Some distros, such as Red Hat Enterprise Linux, support non-superuser munlockall calls.***",
				EPERM,TEST_ERRNO,
				strerror(TEST_ERRNO));
					  
			}
		}
				/* End for TEST_LOOPING */

	/* cleanup and exit */
	cleanup();

	return 0;
}				/* End main */
コード例 #28
0
ファイル: utils.c プロジェクト: kernelslacker/trinity
void * __zmalloc(size_t size, const char *func)
{
	void *p;

	p = malloc(size);
	if (p == NULL) {
		/* Maybe we mlockall'd everything. Try and undo that, and retry. */
		munlockall();
		p = malloc(size);
		if (p != NULL)
			goto done;

		printf("%s: malloc(%zu) failure.\n", func, size);
		exit(EXIT_FAILURE);
	}

done:
	memset(p, 0, size);
	return p;
}
コード例 #29
0
ファイル: vd80spd.c プロジェクト: bradomyn/coht
int main(int argc, char **argv)
{
	int rc = 0;

	if (vd80_map())
		exit(1);

	if (vd80_init())
		exit(1);

	vd80_cmd_setbig(0);

	/* Run a 15 s recording to be sure to get 1M samples */
	if ((rc = test_sampling(15000000)))
		goto out;

	/* Check we've got at least 1M samples */
	if (shot_samples < (1024*1024)) {
		printf("No samples recorded - exiting\n");
		rc = 1;
		goto out;
	}

	/* Make sure we won't be swapped */
	if (mlockall(MCL_CURRENT|MCL_FUTURE)) {
		printf("Failed to lock process address space: %s\n",
		       strerror(errno));
		printf("Results may not be accurate\n");
	}

	/* Read 1M samples (512K frames) from 1 channel */
	if ((rc = time_read_samples(0, 512*1024, 16)))
		goto out;

out:
	rc = vd80_exit();

	munlockall();

	return rc;
}
コード例 #30
0
ファイル: munlockall01.c プロジェクト: CSU-GH/okl4_3.0
int main(int ac, char **av)
{
	int lc;		 		/* loop counter */
	char *msg;			/* message returned from parse_opts */

	if ((msg = parse_opts(ac, av, NULL, NULL)) != (char *) NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
		tst_exit();
	}

	/* perform global setup for test */
	setup();

	/* check looping state */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping. */
		Tst_count = 0;
						
		TEST(munlockall());
			
		/* check return code */
		if (TEST_RETURN == -1) {
			tst_resm(TFAIL, "munlockall() Failed with"
				" return=%d, errno=%d : %s",
				TEST_RETURN, TEST_ERRNO,
				strerror(TEST_ERRNO));
		} else {
			tst_resm(TPASS, "munlockall() passed with"
				" return=%d ",TEST_RETURN);                     			
				
			}
		}
				/* End for TEST_LOOPING */

	/* cleanup and exit */
	cleanup();
	
	return 0;
}				/* End main */