project 2 clarification

74 views
Skip to first unread message

apon...@asu.edu

unread,
Feb 26, 2018, 8:05:34 PM2/26/18
to asu-cse-430
In project two the below instruction is a little unclear. are we supposed to write a run method, or use the one provided as is?

Write the routines called “yield” and “run” which cranks up the works (and put them in threads.h). These routines are defined as:

 

void run()

{   // real code

    Curr_Thread = RunQ

    ucontext_t parent;     // get a place to store the main context, for faking

    getcontext(&parent);   // magic sauce

    swapcontext(&parent, &(Curr_Thread->context));  // start the first thread
}

Partha Dasgupta

unread,
Feb 27, 2018, 12:12:27 PM2/27/18
to asu-c...@googlegroups.com
You can use your own, or use/modify the one provided.


Partha Dasgupta,
ASU/CIDSE/Computer Science & Eng. 
EMail: par...@asu.edu
http://cactus.eas.asu.edu/partha

--
You received this message because you are subscribed to the Google Groups "asu-cse-430" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asu-cse-430+unsubscribe@googlegroups.com.
To post to this group, send email to asu-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/asu-cse-430.
For more options, visit https://groups.google.com/d/optout.

csaar...@gmail.com

unread,
Feb 27, 2018, 1:38:36 PM2/27/18
to asu-cse-430
ok. I am using the one provided but am hitting the issue below. I noticed in the highlighted portion that both registers in swapcontext are the same. Am i reading that right, and might that be causing the issue.?

Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7_4.2.x86_64
(gdb) continue
Continuing.
Thread ID is 1

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a5cc1e in swapcontext () from /lib64/libc.so.6
(gdb) traceback
Undefined command: "traceback".  Try "help".
(gdb) backtrace
#0  0x00007ffff7a5cc1e in swapcontext () from /lib64/libc.so.6
#1  0x0000000000400a7f in run ()
#2  0x0000000000400b38 in main ()
(gdb) info registers
rax            0x0      0
rbx            0x0      0
rcx            0x7fffffffe350   140737488347984
rdx            0x7fffffffe008   140737488347144
rsi            0x603020 6303776
rdi            0x2      2
rbp            0x7fffffffe290   0x7fffffffe290
rsp            0x7fffffffded8   0x7fffffffded8
r8             0x7ffff7a60988   140737348241800
r9             0xe      14
r10            0x8      8
r11            0x206    518
r12            0x603020 6303776
r13            0x7fffffffe380   140737488348032
r14            0x0      0
r15            0x0      0
rip            0x7ffff7a5cc1e   0x7ffff7a5cc1e <swapcontext+158>
eflags         0x10217  [ CF PF AF IF RF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb)


On Tuesday, February 27, 2018 at 10:12:27 AM UTC-7, Partha wrote:
You can use your own, or use/modify the one provided.


Partha Dasgupta,
ASU/CIDSE/Computer Science & Eng. 
EMail: par...@asu.edu
http://cactus.eas.asu.edu/partha

On Mon, Feb 26, 2018 at 6:05 PM, <apon...@asu.edu> wrote:
In project two the below instruction is a little unclear. are we supposed to write a run method, or use the one provided as is?

Write the routines called “yield” and “run” which cranks up the works (and put them in threads.h). These routines are defined as:

 

void run()

{   // real code

    Curr_Thread = RunQ

    ucontext_t parent;     // get a place to store the main context, for faking

    getcontext(&parent);   // magic sauce

    swapcontext(&parent, &(Curr_Thread->context));  // start the first thread
}

--
You received this message because you are subscribed to the Google Groups "asu-cse-430" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asu-cse-430...@googlegroups.com.

csaar...@gmail.com

unread,
Feb 27, 2018, 2:22:23 PM2/27/18
to asu-cse-430
Please disregard. I got it to work by modifying the run method 
Reply all
Reply to author
Forward
0 new messages