Comp-Sci Theory

From Colettapedia
Jump to navigation Jump to search

General

  • Multi-tier architecture
    • Client-server architecture
  • application server
    • JBoss
    • .NET
    • Zend

Processes

  • Process = an instance of a computer program, consisting of one or more threads, that is being sequentially executed by a computer system that has the ability to run several computer programs concurrently.
  • A Completely separate instantiation of a program.

Threads

  • thread = a lightweight process. A flow of control within a process. It is a basic unit of CPU utilization.
    • It comprises of
      1. a thread ID
      2. a program counter
      3. a register set
      4. a stack.
    • If the two threads belong to the same process, they share its code section, data section and other operating system resource.
    • A traditional process has a single thread of control. If the process has multiple threads of control, it can do more than one task at a time.

thread safety

  • In a multi-threaded program, several threads execute simultaneously in a shared address space. Every thread has access to virtually all the memory of every other thread. Thus the flow of control and the sequence of accesses to data often have little relation to what would be reasonably expected by looking at the text of the program, violating the principle of least astonishment. Thread safety is a property aimed at minimizing surprising behavior by re-establishing some of the correspondences between the actual flow of control and the text of the program.

Threads vs. Processes

  • processes are typically independent, while threads exist as subsets of a process
  • processes carry considerable state information, whereas multiple threads within a process share state as well as memory and other resources
  • processes have separate address spaces, whereas threads share their address space
  • processes interact only through system-provided inter-process communication mechanisms.
  • Context switching between threads in the same process is typically faster than context switching between processes.

Fork vs pthreads

  • A child process inherits most of its attributes, such as open files, from its parent. In UNIX, a child process is in fact created (using fork) as a copy of the parent. The child process can then overlay itself with a different program (using exec) as required.

duck typed language

  • polymorphism without inheritance
  • different from interface type system - no explicit interface is defined
  • don't ask for the type of an object before calling a member function on it.
  • type checking occurs at run-time and not compile time
  • If it walks like a duck and quacks like a duck, it could be a dragon doing a duck impersonation. You may not always want to let dragons into a pond, even if they can impersonate a duck.
  • In other words, don't check whether it IS-a duck: check whether it QUACKS-like-a duck, WALKS-like-a duck, etc, etc, depending on exactly what subset of duck-like behaviour you need to play your language-games with.