c++ program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ganeshforall
    New Member
    • Jan 2010
    • 3

    #1

    c++ program

    write a program in c++ to calculate cgpa of student. we are given sgpa of the student and the total number of semisters.
    cgpa= sum of(sgpa*credits in that semister)/total number of credits.
    we have to use header file cgpa.h
    we have to use class name cgpa
    we have to use function name float calccgpa(float sgpa[],int credits[],int noofsem)
    sgpa= sgpa pf different sem
    credits=integer array contains the credits of the sgpa
    return cgpa
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

    Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

    Then when you are ready post a new question in this thread.

    Banfa
    Administrator

    Comment

    • ganeshforall
      New Member
      • Jan 2010
      • 3

      #3
      The following sequence of operations is a schedule of a transaction transferring $1,000 from account1 (i.e., a record acct1) to account2 (i.e., a record acct2). Assume the DBMS supports a lock upgrade whenever applicable.
      s_lock(acct1); // Set a shared lock on acct1

      read(acct1);

      acct1.balance = acct1.balance - 1000;

      x_lock(acct1); // Upgrade the shared lock on acct1 to an exclusive lock

      write(acct1);

      unlock(acct1); // Release the exclusive lock on acct1

      s_lock(acct2); // Set a shared lock on acct2

      read(acct2);

      acct2.balance = acct2.balance + 1000;

      x_lock(acct2); // Upgrade the shared lock on acct2 to an exclusive lock

      write(acct2);

      unlock(acct2); // Release the exclusive lock on acct2

      commit;

      i) The schedule shown above violates the two-phase locking (2PL) protocol and hence does not guarantee a correct result of the transaction. Show a correct schedule that complies with the basic 2PL protocol while maximizing the concurrency.

      ii) One of the problems of the basic 2PL is the risk of a deadlock between concurrent transactions. Deadlocks can be prevented if we use the conservative 2PL. Show a conservative 2PL schedule modified from the basic 2PL in the previous question while, again, maximizing the concurrency level. Note that a lock upgrade is not applicable to the conservative 2PL.

      iii) The conservative 2PL prevents a deadlock but does not guarantee recoverability. For example, DBMS may let a transaction Ta read what has been written by another transaction Tb as soon as Tb releases a lock. Later on, it may happen that Ta has already committed when the transaction Tb has to abort. Strict two-phase locking has been invented to prevent such a situation. Revise the conservative 2PL schedule in the previous question further to comply with the strict 2PL as well.

      Thank you! Any suggestions would be great... I'm really confused how to figure out these problems... step-by-step, if possible, would be great. Thanks!

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Please read Banfa's Post #2 again.

        Comment

        Working...