• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_sys_tune函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中set_sys_tune函数的典型用法代码示例。如果您正苦于以下问题:C++ set_sys_tune函数的具体用法?C++ set_sys_tune怎么用?C++ set_sys_tune使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_sys_tune函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cleanup

void cleanup(void)
{
	set_sys_tune("overcommit_memory", old_overcommit, 0);
	set_sys_tune("max_map_count", old_max_map_count, 0);

	TEST_CLEANUP;
}
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:7,代码来源:max_map_count.c


示例2: overcommit_memory_test

static void overcommit_memory_test(void)
{

#if __WORDSIZE == 32
	tst_brk(TCONF, "test is not designed for 32-bit system.");
#endif
	/* start to test overcommit_memory=2 */
	set_sys_tune("overcommit_memory", 2, 1);

	update_mem_commit();
	alloc_and_check(commit_left * 2, EXPECT_FAIL);
	alloc_and_check(commit_limit, EXPECT_FAIL);
	update_mem_commit();
	alloc_and_check(commit_left / 2, EXPECT_PASS);

	/* start to test overcommit_memory=0 */
	set_sys_tune("overcommit_memory", 0, 1);

	update_mem();
	alloc_and_check(free_total / 2, EXPECT_PASS);
	update_mem();
	alloc_and_check(free_total * 2, EXPECT_FAIL);
	alloc_and_check(sum_total, EXPECT_FAIL);

	/* start to test overcommit_memory=1 */
	set_sys_tune("overcommit_memory", 1, 1);

	alloc_and_check(sum_total / 2, EXPECT_PASS);
	alloc_and_check(sum_total, EXPECT_PASS);
	alloc_and_check(sum_total * 2, EXPECT_PASS);

}
开发者ID:yaneurabeya,项目名称:ltp,代码行数:32,代码来源:overcommit_memory.c


示例3: cleanup

static void cleanup(void)
{
	if (old_overcommit_memory != -1)
		set_sys_tune("overcommit_memory", old_overcommit_memory, 0);
	if (old_overcommit_ratio != -1)
		set_sys_tune("overcommit_ratio", old_overcommit_ratio, 0);
}
开发者ID:yaneurabeya,项目名称:ltp,代码行数:7,代码来源:overcommit_memory.c


示例4: main

int main(int argc, char *argv[])
{
	int lc;

	tst_parse_opts(argc, argv, NULL, NULL);

#if __WORDSIZE == 32
	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
#endif

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		tst_count = 0;

		/* we expect mmap to fail before OOM is hit */
		set_sys_tune("overcommit_memory", 2, 1);
		oom(OVERCOMMIT, 0, ENOMEM, 0);

		/* with overcommit_memory set to 0 or 1 there's no
		 * guarantee that mmap fails before OOM */
		set_sys_tune("overcommit_memory", 0, 1);
		oom(OVERCOMMIT, 0, ENOMEM, 1);

		set_sys_tune("overcommit_memory", 1, 1);
		testoom(0, 0, ENOMEM, 1);
	}
	cleanup();
	tst_exit();
}
开发者ID:Nan619,项目名称:ltp,代码行数:30,代码来源:oom01.c


示例5: cleanup

void cleanup(void)
{
	set_sys_tune("overcommit_memory", old_overcommit_memory, 0);
	set_sys_tune("overcommit_ratio", old_overcommit_ratio, 0);

	TEST_CLEANUP;
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:7,代码来源:overcommit_memory.c


示例6: overcommit_memory_test

static void overcommit_memory_test(void)
{
	/* start to test overcommit_memory=2 */
	set_sys_tune("overcommit_memory", 2, 1);

	update_mem();
	alloc_and_check(commit_left * 2, EXPECT_FAIL);
	alloc_and_check(commit_limit, EXPECT_FAIL);
	update_mem();
	alloc_and_check(commit_left / 2, EXPECT_PASS);

	/* start to test overcommit_memory=0 */
	set_sys_tune("overcommit_memory", 0, 1);

	update_mem();
	alloc_and_check(free_total / 2, EXPECT_PASS);
	update_mem();
	alloc_and_check(free_total * 2, EXPECT_FAIL);
	alloc_and_check(sum_total, EXPECT_FAIL);

	/* start to test overcommit_memory=1 */
	set_sys_tune("overcommit_memory", 1, 1);

	alloc_and_check(sum_total / 2, EXPECT_PASS);
	alloc_and_check(sum_total, EXPECT_PASS);
	alloc_and_check(sum_total * 2, EXPECT_PASS);

}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:28,代码来源:overcommit_memory.c


示例7: setup

void setup(void)
{
	long hpage_size;

	tst_require_root();
	check_hugepage();
	tst_sig(FORK, DEF_HANDLER, cleanup);
	tst_tmpdir();

	orig_hugepages = get_sys_tune("nr_hugepages");
	set_sys_tune("nr_hugepages", hugepages, 1);
	hpage_size = read_meminfo("Hugepagesize:") * 1024;

	shm_size = hpage_size * hugepages / 2;
	update_shm_size(&shm_size);
	shmkey = getipckey(cleanup);
	shm_id_1 = shmget(shmkey, shm_size,
			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
	if (shm_id_1 == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "shmget");

	/* get the userid for a non root user */
	ltp_uid = getuserid(cleanup, ltp_user);

	TEST_PAUSE;
}
开发者ID:CSRedRat,项目名称:ltp,代码行数:26,代码来源:hugeshmctl03.c


示例8: setup

void setup(void)
{
	int ret, memnode;

	tst_require_root();
	tst_sig(FORK, DEF_HANDLER, cleanup);
	TEST_PAUSE;

	if (!is_numa(NULL, NH_MEMS, 1))
		tst_brkm(TCONF, NULL, "requires NUMA with at least 1 node");

	overcommit = get_sys_tune("overcommit_memory");
	set_sys_tune("overcommit_memory", 1, 1);

	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
	write_memcg();

	/*
	 * Some nodes do not contain memory, so use
	 * get_allowed_nodes(NH_MEMS) to get a memory
	 * node. This operation also applies to Non-NUMA
	 * systems.
	 */
	ret = get_allowed_nodes(NH_MEMS, 1, &memnode);
	if (ret < 0)
		tst_brkm(TBROK, cleanup, "Failed to get a memory node "
				      "using get_allowed_nodes()");
	write_cpusets(memnode);
}
开发者ID:1587,项目名称:ltp,代码行数:30,代码来源:oom05.c


示例9: setup

void setup(void)
{
	long hpage_size;

	tst_require_root(NULL);
	tst_sig(NOFORK, DEF_HANDLER, cleanup);
	tst_tmpdir();

	orig_hugepages = get_sys_tune("nr_hugepages");
	set_sys_tune("nr_hugepages", hugepages, 1);
	hpage_size = read_meminfo("Hugepagesize:") * 1024;

	shm_size = hpage_size * hugepages / 2;
	update_shm_size(&shm_size);
	shmkey = getipckey();

	/* create a shared memory segment without read or write permissions */
	shm_id_1 = shmget(shmkey, shm_size, SHM_HUGETLB | IPC_CREAT | IPC_EXCL);
	if (shm_id_1 == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "shmget #1");

	/* create a shared memory segment with read and write permissions */
	shm_id_2 = shmget(shmkey + 1, shm_size,
			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
	if (shm_id_2 == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "shmget #2");

	TEST_PAUSE;
}
开发者ID:MohdVara,项目名称:ltp,代码行数:29,代码来源:hugeshmctl02.c


示例10: setup

void setup(void)
{
	long mem_total, hpage_size;

	tst_require_root();

	mem_total = read_meminfo("MemTotal:");
	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &orig_shmmax);
	SAFE_FILE_PRINTF(NULL, PATH_SHMMAX, "%ld", (long)SIZE);
	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &new_shmmax);

	if (mem_total < 2L*1024*1024)
		tst_brkm(TCONF,	NULL, "Needed > 2GB RAM, have: %ld", mem_total);

	if (new_shmmax < SIZE)
		tst_brkm(TCONF,	NULL, "shmmax too low, have: %ld", new_shmmax);

	orig_hugepages = get_sys_tune("nr_hugepages");
	hpage_size = read_meminfo("Hugepagesize:") * 1024;

	hugepages = (orig_hugepages * hpage_size + SIZE) / hpage_size;
	set_sys_tune("nr_hugepages", hugepages, 1);

	TEST_PAUSE;
}
开发者ID:liaoqingwei,项目名称:ltp,代码行数:25,代码来源:hugeshmat04.c


示例11: setup

void setup(void)
{
	long hpage_size;

	tst_require_root(NULL);
	tst_sig(NOFORK, sighandler, cleanup);
	tst_tmpdir();

	orig_hugepages = get_sys_tune("nr_hugepages");
	set_sys_tune("nr_hugepages", hugepages, 1);
	hpage_size = read_meminfo("Hugepagesize:") * 1024;

	shm_size = hpage_size * hugepages / 2;
	update_shm_size(&shm_size);
	shmkey = getipckey();

	/* create a shared memory resource with read and write permissions */
	shm_id_1 = shmget(shmkey, shm_size,
			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
	if (shm_id_1 == -1)
		tst_brkm(TBROK | TERRNO, cleanup, "shmget");

	/* attach the shared memory segment */
	shared = shmat(shm_id_1, 0, 0);
	if (shared == (void *)-1)
		tst_brkm(TBROK | TERRNO, cleanup, "shmat #1");

	/* give a value to the shared memory integer */
	*shared = 4;

	TEST_PAUSE;
}
开发者ID:AbhiramiP,项目名称:ltp,代码行数:32,代码来源:hugeshmdt01.c


示例12: setup

static void setup(void)
{
	int memnode, ret;

	if (!is_numa(NULL, NH_MEMS, 1))
		tst_brk(TCONF, "requires NUMA with at least 1 node");

	overcommit = get_sys_tune("overcommit_memory");
	set_sys_tune("overcommit_memory", 1, 1);

	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
	cpuset_mounted = 1;

	/*
	 * Some nodes do not contain memory, so use
	 * get_allowed_nodes(NH_MEMS) to get a memory
	 * node. This operation also applies to Non-NUMA
	 * systems.
	 */
	ret = get_allowed_nodes(NH_MEMS, 1, &memnode);
	if (ret < 0)
		tst_brk(TBROK, "Failed to get a memory node "
			      "using get_allowed_nodes()");
	write_cpusets(memnode);
}
开发者ID:sathnaga,项目名称:ltp,代码行数:25,代码来源:oom04.c


示例13: setup

void setup(void)
{
	int memnode, ret;

	tst_require_root(NULL);
	tst_sig(FORK, DEF_HANDLER, cleanup);
	TEST_PAUSE;

	overcommit = get_sys_tune("overcommit_memory");
	set_sys_tune("overcommit_memory", 1, 1);

	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);

	/*
	 * Some nodes do not contain memory, so use
	 * get_allowed_nodes(NH_MEMS) to get a memory
	 * node. This operation also applies to Non-NUMA
	 * systems.
	 */
	ret = get_allowed_nodes(NH_MEMS, 1, &memnode);
	if (ret < 0)
		tst_brkm(TBROK, NULL, "Failed to get a memory node "
				      "using get_allowed_nodes()");
	write_cpusets(memnode);
}
开发者ID:MohdVara,项目名称:ltp,代码行数:25,代码来源:oom04.c


示例14: cleanup

void cleanup(void)
{
	set_sys_tune("overcommit_memory", overcommit, 0);
	umount_mem(CPATH, CPATH_NEW);

	TEST_CLEANUP;
}
开发者ID:MohdVara,项目名称:ltp,代码行数:7,代码来源:oom04.c


示例15: setup

void setup(void)
{
	long mem_total, swap_total;

	tst_require_root(NULL);

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	TEST_PAUSE;

	if (access(PATH_SYSVM "overcommit_memory", F_OK) == -1 ||
	    access(PATH_SYSVM "overcommit_ratio", F_OK) == -1)
		tst_brkm(TCONF, NULL, "The system "
			 "can't support to test %s", TCID);

	old_overcommit_memory = get_sys_tune("overcommit_memory");
	old_overcommit_ratio = get_sys_tune("overcommit_ratio");

	set_sys_tune("overcommit_ratio", overcommit_ratio, 1);

	mem_total = read_meminfo("MemTotal:");
	tst_resm(TINFO, "MemTotal is %ld kB", mem_total);
	swap_total = read_meminfo("SwapTotal:");
	tst_resm(TINFO, "SwapTotal is %ld kB", swap_total);
	sum_total = mem_total + swap_total;

	commit_limit = read_meminfo("CommitLimit:");
	tst_resm(TINFO, "CommitLimit is %ld kB", commit_limit);
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:29,代码来源:overcommit_memory.c


示例16: cleanup

static void cleanup(void)
{
	if (overcommit != -1)
		set_sys_tune("overcommit_memory", overcommit, 0);
	if (cpuset_mounted)
		umount_mem(CPATH, CPATH_NEW);
}
开发者ID:sathnaga,项目名称:ltp,代码行数:7,代码来源:oom04.c


示例17: cleanup

void cleanup(void)
{
	rm_shm(shm_id_1);

	set_sys_tune("nr_hugepages", orig_hugepages, 0);

	tst_rmdir();
}
开发者ID:foss-for-synopsys-dwc-arc-processors,项目名称:ltp,代码行数:8,代码来源:hugeshmget01.c


示例18: cleanup

void cleanup(void)
{
	unlink(TEMPFILE);
	set_sys_tune("nr_hugepages", orig_hugepages, 0);

	umount(Hopt);
	tst_rmdir();
}
开发者ID:JanyHuang,项目名称:ltp,代码行数:8,代码来源:hugemmap02.c


示例19: setup

void setup(void)
{
	tst_require_root(NULL);
	tst_sig(FORK, DEF_HANDLER, cleanup);
	TEST_PAUSE;

	overcommit = get_sys_tune("overcommit_memory");
	set_sys_tune("overcommit_memory", 1, 1);
	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
}
开发者ID:MohdVara,项目名称:ltp,代码行数:10,代码来源:oom03.c


示例20: setup

void setup(void)
{
	tst_require_root(NULL);
	tst_sig(FORK, DEF_HANDLER, cleanup);
	TEST_PAUSE;

	overcommit = get_sys_tune("overcommit_memory");
	set_sys_tune("overcommit_memory", 1, 1);
	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
}
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:10,代码来源:oom02.c



注:本文中的set_sys_tune函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_sysinfo_in_ram函数代码示例发布时间:2022-05-30
下一篇:
C++ set_str函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap