The
Questions tagged [ucontext]
64 questions
1
vote
1 answer
Considering makecontext() what is uc_stack.ss_size good for?
Prior to calling makecontext why do we need to set the stack size ss_size?
I just had an unit test case for makecontext/swapcontext snippet and it failed with SIGSEGV. What happened was that stack size was too small and unrelated memory (happened to…

ezegoing
- 526
- 1
- 4
- 18
1
vote
1 answer
How to pass ellipsis argument to makecontext, which also accepts ellipsis argument in C?
I have a function that runs other functions, and these functions can have a variable number of arguments.
The parameter of this function is then passed to makecontext, which attaches the function to a ucontext_t structure, but the problem is this…

doctopus
- 5,349
- 8
- 53
- 105
1
vote
1 answer
Why does printing to stderr cause segmentation fault when dealing with ucontext?
I was working on a project for a course on Operating Systems. The task was to implement a library for dealing with threads, similar to pthreads, but much more simpler. The purpose of it is to practice scheduling algorithms. The final product is a .a…

Yuri J
- 129
- 7
1
vote
1 answer
Why I get segmentation fault when I the signal
I got segmentation fault when I deal with the signalSIGALARM.
Here is my code.
class UThread{
public:
UThread(){}
~UThread(){
signal(SIGALRM,SIG_IGN);
for(size_t i=0;i

huangweiwei
- 161
- 1
- 2
- 9
1
vote
0 answers
setcontext() segmentation fault in normal run but works well under gdb
I'm trying to build an operating system project which gets the current thread's context and serialize, send it over the network to another machine and pick up where the thread left off and continue. (So-called thread-migrator).
I managed to finish…

Ryan
- 373
- 4
- 15
1
vote
0 answers
how to know what is the running context
I am writing a small program in C that creates an array of three structures of type ucontext_t. The program uses swapcontext command to switch between these 3 contexes.
My question is: do I have any ability to know the identity of the context that…

CrazySynthax
- 13,662
- 34
- 99
- 183
1
vote
2 answers
Segmentation fault with ucontext makecontext on OS X 10.10
#include
#include
#define _XOPEN_SOURCE 600
#include
/* Tests creation.
Should print "Hello World!" */
typedef struct thread_t{
ucontext_t thread_context;
}thread_t;
void *thr1(void *in) {
printf("Hello…

Zizheng Wu
- 646
- 1
- 12
- 21
1
vote
1 answer
segmentation fault in setcontext
I'm doing some test on how a scheduler schedules a waiting thread and in the process, I want to not let OS to see a waiting thread, so I kill a thread which is waiting on a lock and start it when the lock is released, I think I should save the…

zmeftah
- 148
- 1
- 2
- 10
1
vote
2 answers
No such file found with semaphore.h and ucontext.h
I have my code here:
#define _GNU_SOURCE
#include "lib-ult.h"
#include
#include
#include
#include
#define TRUE 1
#define FALSE 0
#define FAILURE -1
typedef struct Node {
ucontext_t* context;
…

Cassidy
- 3,328
- 5
- 39
- 76
1
vote
1 answer
Implementing a user-level thread library but code keep seg-faulting, any ideas why?
So as the title says, my code keeps seg-faulting unfortunately. I'm pretty sure I malloc'd everything correctly and I believe that my functions are correct for the test case I have but it still seg-faults. I just wanted to see if anyone could maybe…

VakarianWrex
- 53
- 2
- 9
1
vote
1 answer
what is the right way to operate `ucontext_t`?
From source code of Redis, in file src/debug.c, it use the backtrace() to log the call stack. within these operation, I noticed the getMcontextEip(), it seems like that in Linux:
static void *getMcontextEip(ucontext_t *uc) {
/* Linux */
#if…

coanor
- 3,746
- 4
- 50
- 67
0
votes
1 answer
Is there a way to create a global infinite loop, irrespective of current ucontext (Linux C)?
I am using to swap between different tasks in my "task manager" program. The tasks (functions) are in a linked list and a timer is sending signals in regular intervals to a signal handler which swaps the current context to the next task…

momchil milkov
- 11
- 4
0
votes
0 answers
Why is not this switch to the point (context) where it was called?
I'm implementing in locker in this thread-like library. However, it's suppose to run the statement in the main thread, check if the locker was released, back and forth, until it's the mutex released. So let's say I have this piece of code inside a…

Jack
- 16,276
- 55
- 159
- 284
0
votes
0 answers
How to set sigmask and do a long jump atomically in my signal handler?
I am implementing a coroutine scheduler. A thread is interrupted(by SIGURG) regularly to make a switch. I am using swapcontext(from ucontext.h) in sighandler to achieve that. But I found swapcontext doesn't atomically set sigmask and do a long jump.…

Markity
- 193
- 8
0
votes
0 answers
glibc ucontext: how does setcontext set the sigmask?
This is the structure of ucontext_t:
typedef struct ucontext_t
{
unsigned long int __ctx(uc_flags);
struct ucontext_t *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
struct _libc_fpstate…

Markity
- 193
- 8