Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LiTL with recent libraries #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/interpose.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static void *lp_start_routine(void *_arg) {
return res;
}

int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
int __pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) {
DEBUG_PTHREAD("[p] pthread_create\n");
struct routine *r = malloc(sizeof(struct routine));
Expand All @@ -415,6 +415,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,

return REAL(pthread_create)(thread, attr, lp_start_routine, r);
}
__asm__(".symver __pthread_create,pthread_create@@" GLIBC_2_2_5);
__asm__(".symver __pthread_create,pthread_create@" GLIBC_2_34);

int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr) {
Expand Down
2 changes: 2 additions & 0 deletions src/interpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
fprintf(stderr, "WARNING: unable to find symbol: %s.\n", S(name)); \
} while (0)

#define GLIBC_2_2_5 "GLIBC_2.2.5"
#define GLIBC_2_3_2 "GLIBC_2.3.2"
#define GLIBC_2_34 "GLIBC_2.34"

extern int (*REAL(pthread_mutex_init))(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr);
Expand Down
5 changes: 5 additions & 0 deletions src/interpose.map
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ GLIBC_2.3.2 {
pthread_cond_wait;
pthread_cond_timedwait;
} GLIBC_2.2.5;

GLIBC_2.34 {
global:
pthread_create;
} GLIBC_2.3.2;
6 changes: 3 additions & 3 deletions src/mcstp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* is preempted.
* Indeed, a thread A can overtake another thread B behind which it has been
* waiting for a long time.
* The waiting thread A will first yield its CPU (via pthread_yield) in order to
* The waiting thread A will first yield its CPU (via sched_yield) in order to
* create an opportunity for the preempted thread (lock holder or B) to make
* progress.
* If this is not enough, T will overtake the predecessor thread (B) by marking
Expand Down Expand Up @@ -144,7 +144,7 @@ int mcs_tp_mutex_trylock(mcs_tp_mutex_t *impl, mcs_tp_node_t *me) {
goto success;
} else if (me->status == FAILED) {
if (GET_TIME() - impl->cs_start_time > MAX_CS_TIME)
pthread_yield();
sched_yield();

me->last_lock = impl;
return EBUSY;
Expand All @@ -164,7 +164,7 @@ int mcs_tp_mutex_trylock(mcs_tp_mutex_t *impl, mcs_tp_node_t *me) {
}

if (GET_TIME() - impl->cs_start_time > MAX_CS_TIME)
pthread_yield();
sched_yield();

me->last_lock = impl;
return EBUSY;
Expand Down
4 changes: 0 additions & 4 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ static inline uint64_t rdtsc(void) {
return low | ((uint64_t)high) << 32;
}

static inline int gettid() {
return syscall(SYS_gettid);
}

// EPFL libslock
#define my_random xorshf96
#define getticks rdtsc
Expand Down