1. The second prompt is revealed! (Q2 2018)

    "Breaking into Snape's office in the middle of the night was a risky move at the best of times..."

    Deadline is June 18th, also known as the 22nd Anniversary of a seriously sad day—a tremendously black day for anyone.

    As with before you can check out the new thread discussing scoring, rules, and other such matters in the in the Story Competitions forum.

    Dismiss Notice

TOMD 4: The Tribraggart Tournament

Discussion in 'Real Life Discussion' started by Peace, Oct 14, 2015.

  1. theronin

    theronin Order Member

    Joined:
    Jan 17, 2013
    Messages:
    836
    Weird memory access bugs are always fun. We had a bunch of them pop up at my job recently because we switched compilers, and the the different memory allocation of the new compiler exposed a bunch of unsafe string operations and other similar stuff people had been doing for years.
     
  2. Nazgus

    Nazgus Headmaster

    Joined:
    Mar 16, 2011
    Messages:
    1,052
    Location:
    USA
    @Oz: The language is C, and the context is we're implementing features in the basic OS Pintos. Specifically, we were modifying existing code to respect priorities so that the scheduler works off of a round robin priority queue instead of just a basic queue. The code in question was within the thread_set_priority() function that lets a thread update its priority. Since we have to deal with priority donations later on, we added an effective_priority integer variable to the main thread struct, and updated thread_set_priority() to also update that value to ensure that the thread will be treated fairly in the PQ (which goes off of the effective_priority instead of the base priority).

    For the code itself, here is the function, with the first line being what is originally there, and the other three being what we added:

    Code:
    void thread_set_priority (int new_priority)  {
      thread_current ()->priority = new_priority;
      printf("begin\n");
      thread_current ()->effective_priority = new_priority;
      printf("end\n");
    }
    Now, after messing around with it some more, I discovered that it works once I implement the functionality of having a thread yield if it changes its priority and discovers there is now a higher priority thread that should be running instead:
    Code:
    void thread_set_priority (int new_priority) {
      thread_current ()->priority = new_priority;
      thread_current ()->effective_priority = new_priority;
      int top_p = list_entry (list_max (&ready_list, effective_priority_less, NULL),
        struct thread, elem)->effective_priority;
      if (top_p > new_priority) {
        thread_yield ();
      }
    }
    This seems to explain the test failing, since the main thread would keep executing when it should've yielded. It also explains why the print statements and empty for loops would made it function properly, since either one was keeping it busy for long enough for the its allotted time elapsed and the other threads (which now have a higher priority than it) to take over even though it hadn't yield.

    However, I still don't really understand why it was failing with a page fault since the output memory that was being accessed earlier than it should (since the other threads haven't run to completion yet) is allocated in this main thread, and the other threads don't seem to be accessing it.

    On your question @Chilli , gdb tends to be our go-to debugger, but it's a little hard to use in this project since we're implementing an OS that is by nature running multiple threads throughout the course of the test. It's the first project, so we haven't had too much practice debugging under these conditions.

    To be honest the main takeaway for me is to take a step back and implement features fully instead of by tests. It's how I usually approach projects, but my project partners prefer test driven development. It's usually a good idea, but when the tests were provided for you it becomes easier to miss that you should've implemented something else before running this one imo.
     
  3. Eilyfe

    Eilyfe Headmaster

    Joined:
    May 27, 2014
    Messages:
    1,084
    Cut myself on paper this fine morning and subsequently had the sudden epiphany that Konan's attacks aren't as whimpy as I always thought they were.
     
  4. Darth_Revan

    Darth_Revan Secret Squirrel Prestige DLP Supporter

    Joined:
    Mar 13, 2006
    Messages:
    564
    Gender:
    Male
    Location:
    New England
    High Score:
    2810
    TOMD: Took care of this year's taxes.

    As usual, it's an experience a bit like walking through a maze blindfolded, bumping off the walls.

    Is this the number they mean when they say all those words?

    Oh god, did I remember to add Line 42 to Line 17???
     
  5. Joe's Nemesis

    Joe's Nemesis High Score: 2,058 Prestige

    Joined:
    Jan 29, 2012
    Messages:
    1,076
    High Score:
    2,058
    Yeah, I gotta do the same. Not looking forward to it.

    TOMD - realized I have an internal fear of clinking on any link listed by a person with the screenname of @Spanks
     
  6. Zombie

    Zombie John Waynes Teeth Prestige DLP Supporter

    Joined:
    Apr 28, 2007
    Messages:
    1,350
    Location:
    Within the Garden of Nurgle.
    High Score:
    2,094
    You can subtract 17 from 42, probably wouldn't want to add your exemptions line to your rental real-estate line :p

    Fuck taxes. Finished mine the other day and smoked the biggest bowl ever. I really shouldn't have but it was worth it after that goddamn headache.

    Update on the house keeper's kid for those who follow my life. He's getting better and out of intensive care, my accountant had a heart attack and had to have bypass surgery. The only thing I think that saved him was his percentage from my tax preparation this year. He didn't want to die before he could cash his check.
     
    Last edited: Feb 25, 2018
  7. why?

    why? Sixth Year

    Joined:
    Jun 30, 2017
    Messages:
    174
    High Score:
    0
    @Zombie
    What's wrong with the odd bowl? Or have you switched to vapes/edibles?
     
  8. Zombie

    Zombie John Waynes Teeth Prestige DLP Supporter

    Joined:
    Apr 28, 2007
    Messages:
    1,350
    Location:
    Within the Garden of Nurgle.
    High Score:
    2,094
    I do edibles mostly. I try to stay away from smoking anymore because lung cancers a bitch but sometimes there's nothing like a good smoke..
     
  9. why?

    why? Sixth Year

    Joined:
    Jun 30, 2017
    Messages:
    174
    High Score:
    0
    Shit, that’s rough. Sorry, I’m not sure how else to respond.

    I get it re: smoking though. I was never able to switch to vaping. I realised I actually enjoyed toxic fumes entering my mouth and going through my lungs. God, I used to smoke unfiltered Camels, those things are nasty.

    Edibles are great though.
     
  10. Jarizok

    Jarizok Groundskeeper

    Joined:
    Sep 22, 2015
    Messages:
    342
    Gender:
    Male
    Location:
    Netherlands
    TomD: Received my salary today. This is noteworthy because I do not currently have a job.

    My last day at my old job was the 15th of January but I guess no one thought to tell the people in charge of salaries that I don’t work for them anymore?

    This is pretty sweet as I was actually struggling to get my old landlady to pay me back my deposit. With her in Malta and me back in the Netherlands this had become tricky (she’s straight up refusing to answer any correspondence). I now plan to call the company on Malta about the salary thing, pay them back what they gave me (assuming it was accidental) minus 800 euro (the deposit) and tell them to go get that from the landlady. They’re on Malta anyway and have the resources.

    Am I morally corrupt now?
     
    Oz
  11. momo

    momo Third Year

    Joined:
    Jan 19, 2017
    Messages:
    99
    Location:
    AMERICA
    High Score:
    0
    You are definitely not morally corrupt. In fact, you are a great person! Most people in your situation would probably keep the salary.
     
  12. Giovanni

    Giovanni God of Scotch

    Joined:
    Aug 4, 2005
    Messages:
    8,438
    Location:
    Gilligan's Island
    TOMD: Back East visiting family, friends, and dealing with various messes. Dad has a lung infection, and an additional illness on top of that and refuses to visit the doctor because reasons.

    He's 70. Tomorrow I'm dragging him, likely kicking and screaming, to the doctor.
     
  13. Zombie

    Zombie John Waynes Teeth Prestige DLP Supporter

    Joined:
    Apr 28, 2007
    Messages:
    1,350
    Location:
    Within the Garden of Nurgle.
    High Score:
    2,094
    I think in Monopoly that was called a Bank Error in Your Favor.
     
  14. Fenraellis

    Fenraellis Minister of Magic

    Joined:
    Dec 29, 2007
    Messages:
    1,395
    Location:
    In the Comfy Chair
    Could it have been something as simple as a delayed release of calculated pay from accumulated sick days and/or time off? I've had it that I receives three checks for varying amounts after I had already left a job. Based on accrued Sick days, paid time off and some sort of bonus or something, if I remember right.

    More likely, it was just an accounting error, though, yes.
     
  15. Nazgus

    Nazgus Headmaster

    Joined:
    Mar 16, 2011
    Messages:
    1,052
    Location:
    USA
    TOMD: While debugging a bizarre bug in one of my functions, I happened to notice a bug in another function that would be called later in the program, but isn't being called before the bug occurs. I fixed that, and it fixed the bug. I honestly have no idea what's going on here.

    I have a midterm tomorrow so that takes priority for now, but I'll be going to office hours afterwards to check in about this try and hunt down what was happening.
     
  16. Mordecai

    Mordecai Drunken Scotsman Prestige DLP Supporter

    Joined:
    Nov 11, 2005
    Messages:
    406
    Location:
    Scotland
    High Score:
    3,485
    So I travelled down to Manchester yesterday for a job interview. Now it looks like I'll be crashing on a friends sofa until at least Friday because of the snow. Fun times...
     
  17. Aekiel

    Aekiel Angle of Mispeling Prestige DLP Supporter

    Joined:
    Mar 16, 2006
    Messages:
    894
    Location:
    The Shire
    High Score:
    9,373
    Yeah, I've been hearing about how everywhere but where I'm living is getting buried by the stuff. I guess Gloucestershire is too good for snow.
     
  18. Oment

    Oment The Betrayer

    Joined:
    Apr 11, 2011
    Messages:
    1,814
    Bournemouth was also snow-free, someone I know said. Two segments of England that were saved from the apocalypse.
     
  19. Teyrn

    Teyrn Professor

    Joined:
    May 23, 2014
    Messages:
    408
    Gender:
    Male
    Location:
    Frozen North
    It's so cute how a little snow makes brits panic.
     
  20. Arthellion

    Arthellion Death Eater

    Joined:
    Apr 14, 2017
    Messages:
    920
    Gender:
    Male
    Location:
    Georgia, USA
    High Score:
    0
    TOMD: My Anakin Skywalker Quest has over 11k replies. So...that's going well.

    In other news was appointed to the position of Chief Justice at my University's Student Government. Its a year long appointment unless I resign. Good resume builder.
     
Loading...
Similar Threads
  1. Oz
    Replies:
    2,358
    Views:
    309,428