Skip to content
Snippets Groups Projects
Commit 4ed5892a authored by Vasiliy Soshnikov's avatar Vasiliy Soshnikov
Browse files

#638, checking/configuring in cmake pthread_yield and sched_yield;...

#638, checking/configuring in cmake pthread_yield and sched_yield; READLINE_ROOT for better readline control;
parent 1a5e2f16
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,9 @@ check_include_file(sys/prctl.h HAVE_PRCTL_H)
check_symbol_exists(O_DSYNC fcntl.h HAVE_O_DSYNC)
check_symbol_exists(fdatasync unistd.h HAVE_FDATASYNC)
check_symbol_exists(pthread_yield pthread.h HAVE_PTHREAD_YIELD)
check_symbol_exists(sched_yield sched.h HAVE_SCHED_YIELD)
check_function_exists(memmem HAVE_MEMMEM)
check_function_exists(memrchr HAVE_MEMRCHR)
check_function_exists(sendfile HAVE_SENDFILE)
......
......@@ -7,8 +7,21 @@
#
include(FindTermcap)
FIND_LIBRARY(READLINE_READLINE_LIBRARY NAMES readline)
FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
if (DEFINED READLINE_ROOT)
set(_FIND_OPTS NO_CMAKE NO_CMAKE_SYSTEM_PATH)
FIND_LIBRARY(READLINE_READLINE_LIBRARY
NAMES readline
HINTS ${READLINE_ROOT}/lib
${_FIND_OPTS})
FIND_PATH(READLINE_INCLUDE_DIR
NAMES readline/readline.h
HINTS ${READLINE_ROOT}/include
${_FIND_OPTS})
else()
FIND_LIBRARY(READLINE_READLINE_LIBRARY NAMES readline)
FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
endif()
SET(READLINE_FOUND FALSE)
IF (READLINE_READLINE_LIBRARY AND READLINE_INCLUDE_DIR)
......
......@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <unistd.h>
#if defined(__cplusplus)
extern "C" {
......
......@@ -127,6 +127,8 @@
#cmakedefine ENABLE_BUNDLED_LIBEIO 1
#cmakedefine ENABLE_BUNDLED_LIBCORO 1
#cmakedefine HAVE_PTHREAD_YIELD 1
#cmakedefine HAVE_SCHED_YIELD 1
#cmakedefine HAVE_PRCTL_H 1
......
#include "small/quota.h"
#include <pthread.h>
#include "test.h"
struct quota quota;
......@@ -18,6 +19,15 @@ struct thread_data {
pthread_t threads[THREAD_CNT];
thread_data datum[THREAD_CNT];
static inline void do_yield()
{
#ifdef HAVE_PTHREAD_YIELD
pthread_yield();
#elif HAVE_SCHED_YIELD
sched_yield()
#endif
}
void *thread_routine(void *vparam)
{
struct thread_data *data = (struct thread_data *)vparam;
......@@ -32,7 +42,7 @@ void *thread_routine(void *vparam)
}
ssize_t max = rand() % QUOTA_MAX;
max = quota_set(&quota, max);
pthread_yield();
do_yield();
if (max > 0) {
data->last_lim_set = max;
data->lim_change_success++;
......@@ -42,7 +52,7 @@ void *thread_routine(void *vparam)
allocated_size = -1;
data->use_change = 0;
data->use_change_success++;
pthread_yield();
do_yield();
} else {
allocated_size = rand() % max + 1;
allocated_size = quota_use(&quota, allocated_size);
......@@ -50,7 +60,7 @@ void *thread_routine(void *vparam)
data->use_change = allocated_size;
data->use_change_success++;
}
pthread_yield();
do_yield();
}
}
return (void *)check_fail_count;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment