Method for specifying and verifying multi-threaded object-oriented programs with invariants
First Claim
1. A method comprising:
- executing multiple threads on a computer;
a thread T1 acquiring a lock on a top object in a hierarchy of objects, wherein an invariant condition is specified for the top object, the invariant condition specifies a relation on data of the top object, and the invariant condition references at least two fields, wherein the at least two fields are of at least two different objects;
wherein acquiring the lock changes ownership to thread T1 of the top object;
wherein ownership confers upon thread T1 a right to modify any field of the top object;
wherein the lock excludes all other threads from accessing the top object and any descendant objects in the hierarchy of objects;
after acquiring the lock, unpacking the top object, wherein unpacking the top object comprises designating the top object as being of a mutable state, which allows invariants to be temporarily violated and allows field assignments of the top object that temporarily violate the invariant condition; and
packing the top object, wherein packing the top object comprises verifying that the invariant condition holds and taking the top object from the mutable state to designated as being of a consistent state, wherein being designated as being of a consistent state prevents further modifications.
2 Assignments
0 Petitions
Accused Products
Abstract
Various new and non-obvious systems and methods for ensuring within a multi-threaded environment that object fields hold legal values are disclosed. One of the disclosed embodiments is a method for a thread locking the top object of an object hierarchy. The thread then gains ownership of the locked object and any children of the locked object, by successively unpacking child objects, allowing the thread to write to any unpacked object field. By owning the top hierarchical object, the thread also achieves transitive ownership to any descendants of the object, allowing the thread to read any object fields which it transitively owns. When a thread locks an object within this exemplary embodiment all other threads are denied access to the locked object and to any descendants of the locked object.
-
Citations
15 Claims
-
1. A method comprising:
-
executing multiple threads on a computer; a thread T1 acquiring a lock on a top object in a hierarchy of objects, wherein an invariant condition is specified for the top object, the invariant condition specifies a relation on data of the top object, and the invariant condition references at least two fields, wherein the at least two fields are of at least two different objects; wherein acquiring the lock changes ownership to thread T1 of the top object; wherein ownership confers upon thread T1 a right to modify any field of the top object; wherein the lock excludes all other threads from accessing the top object and any descendant objects in the hierarchy of objects; after acquiring the lock, unpacking the top object, wherein unpacking the top object comprises designating the top object as being of a mutable state, which allows invariants to be temporarily violated and allows field assignments of the top object that temporarily violate the invariant condition; and packing the top object, wherein packing the top object comprises verifying that the invariant condition holds and taking the top object from the mutable state to designated as being of a consistent state, wherein being designated as being of a consistent state prevents further modifications. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-
-
12. A computer system having a multi-threaded operating system, the computer system comprising:
-
one or more processing units; memory; at least one thread with a thread table for determining object ownership; at least two objects hierarchically arranged, at least one object further comprising; an owner field for determining an entity that owns the at least one object; and at least one variable field; a thread-object consistency module which ensures that for each thread-object transition, the thread table indicates that a thread owns the at least one object and the owner field indicates that the at least one object is owned by the thread; a writer module which writes a value into the variable field if the at least one object is owned by a thread requesting write access; a representation of an invariant condition specified for a top object of the at least two objects, wherein the invariant condition specifies a relation on data of the top object, and the invariant condition references at least two fields, wherein the at least two fields are in at least two different objects; a variable indicating whether the invariant condition holds; wherein an unpack statement switches the variable off and designates the top object as being of a mutable state, which allows invariants to be temporarily violated and allows field assignments of the top object that temporarily violate the invariant condition; and wherein a pack statement switches the variable on, verifies that the invariant condition holds, and takes the top object from the mutable state to designated as being of a consistent state, wherein being designated as being of a consistent state prevents further modifications. - View Dependent Claims (13, 14)
-
-
15. A method comprising:
-
executing multiple threads on a computer; a thread T1 acquiring a lock on an object in a hierarchy of objects, wherein an invariant condition is specified for the object, and the invariant condition specifies a relation on data of the top object, and the invariant condition comprises legal values for at least two fields in two different objects; wherein acquiring the lock changes ownership to thread T1 of the object; wherein ownership confers upon thread T1 rights to modify any field of the object; wherein the lock excludes other threads from accessing the object and any descendant objects in the hierarchy of objects; after acquiring the lock, unpacking the object, wherein unpacking the object comprises designating the object as being of a mutable state, which allows invariants to be temporarily violated and temporarily allows field assignments of the object that violate the invariant condition; packing the object, wherein packing the object comprises (a)-(b); (a) checking whether the invariant condition holds; (b) choosing between taking the object from the mutable state to a consistent state, provided the invariant condition holds and generating an error condition if the invariant condition does not hold; and wherein the hierarchy of objects is defined via a definition comprising a keyword specifying object ownership of one or more fields; and wherein being designated as being of a consistent state prevents further modifications.
-
Specification