throbber
10/19/2015
`
`users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Sequential and Multithreaded Quicksort Function Definitions                */
`/*                                                                            */
`/* Written by: John Thornley, Computer Science Dept., Caltech.                */
`/* Date: October, 1997.                                                       */
`/*                                                                            */
`/* Algorithm:                                                                 */
`/* ‐ recursive quicksort.                                                     */
`/* ‐ median of first, middle, and last item chosen as pivot in partitioning.  */
`/* ‐ insertion sort of base‐case arrays.                                      */
`/* ‐ separate threads for recursive quicksort calls.                          */
`/* ‐ sequential quicksort after enough threads created.                       */
`/*                                                                            */
`/* Copyright (c) 1997 by John Thornley.                                       */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`#include <stdio.h>
`#include <assert.h>
`#include <sthreads.h>
`#include <bool.h>
`#include "quicksort.h"
`
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Base‐case length (below which insertion sort is faster than quicksort)     */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`#define BASE_LENGTH 64 /* 64 works well for 200 MHz Pentium Pro */ 
`
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Handle errors from Sthreads function calls                                 */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`void handle_sthread_error(int error_code)
`
`{ 
`
`   char error_message[100];
`
`    if (error_code != STHREAD_ERROR_NONE) {
`        sthread_sprint_error(error_message, error_code);
`        fprintf(stderr, "Sthread error: %s\n", error_message);
`        exit(EXIT_FAILURE);
`    }
`
`} /
`
`*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Insertion sort for sorting base‐case arrays                                */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`static void insertion_sort(int n, item data[])
`
`{ 
`
`   int i, j, k;
`    item temp;
`
`    assert(n >= 0);
`
`    for (i = 1; i < n; i++) {
`        temp = data[i];
`        k = 0;
`        for (j = i ‐ 1; j >= 0; j‐‐)
`            if (temp < data[j])
`                data[j + 1] = data[j];
`
`http://users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`1/4
`
`1
`
`AMI/MSI/GBT EX 1009
`IPR of Pat. No. 6,282,641
`
`

`
`users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`10/19/2015
`            else {
`                k = j + 1;
`                break;
`            }
`        data[k] = temp;
`    }
`
`} /
`
`*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Swap two items                                                             */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`#define SWAP(x, y) {item temp; temp = x; x = y; y = temp;}
`
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Choose pivot value and partition data array                                */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`static void partition(int n, item data[], int *pivot)
`
`{ 
`
`   item pivot_value;
`    int left, right;
`
`    assert(n >= 3);
`
`    SWAP(data[1], data[(n ‐ 1)/2])
`    if (data[1] > data[n ‐ 1])
`        SWAP(data[1], data[n ‐ 1])
`    if (data[0] > data[n ‐ 1])
`        SWAP(data[0], data[n ‐ 1])
`    if (data[1] > data[0])
`        SWAP(data[1], data[0])
`    pivot_value = data[0];
`    left = 1; right = n ‐ 1;
`    while (true) {
`        do left++; while (data[left] < pivot_value);
`        do right‐‐; while (data[right] > pivot_value);
`        if (right < left) break;
`        SWAP(data[left], data[right])
`    }
`    data[0] = data[right];
`    data[right] = pivot_value;
`    *pivot = right;
`
`} /
`
`*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Sequential quicksort                                                       */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`void seq_quicksort(int n, item data[])
`
`{ 
`
`   assert(n >= 0);
`    assert(BASE_LENGTH >= 2);
`
`    if (n <= BASE_LENGTH)
`        insertion_sort(n, data);
`    else {
`        int pivot;
`
`        partition(n, data, &pivot);
`        seq_quicksort(pivot, &data[0]);
`http://users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`2/4
`
`2
`
`

`
`users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`10/19/2015
`        seq_quicksort(n ‐ pivot ‐ 1, &data[pivot + 1]);
`    }
`
`} /
`
`*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Multithreaded quicksort (pragma version)                                   */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/*
`void multi_quicksort(int n, item data[], int t)
`
`{ 
`
`   assert(n >= 0);
`    assert(BASE_LENGTH >= 2);
`    assert(t >= 1);
`
`    if (n <= BASE_LENGTH || t == 1)
`        seq_quicksort(n, data);
`    else {
`        int pivot;
`
`        partition(n, data, &pivot);
`        #pragma multithreadable
`        {
`            multi_quicksort(pivot, &data[0], t ‐ t/2);
`            multi_quicksort(n ‐ pivot ‐ 1, &data[pivot + 1], t/2);
`        }
`    }
`
`}*
`
`/
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`/* Multithreaded quicksort (Sthreads version)                                 */
`/*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`typedef struct {
`    int n, t, pivot;
`    item *data;
`} block_args;
`
`static void statement_0(block_args *args)
`
`{ 
`
`   multi_quicksort(
`        args‐>pivot, &(args‐>data)[0], args‐>t ‐ args‐>t/2);
`
`} s
`
`{ 
`
`   multi_quicksort(
`        args‐>n ‐ args‐>pivot ‐ 1, &(args‐>data)[args‐>pivot + 1], args‐>t/2);
`
`tatic void statement_1(block_args *args)
`
`oid multi_quicksort(int n, item data[], int t)
`
`} v
`
`{ 
`
`   assert(n >= 0);
`    assert(BASE_LENGTH >= 2);
`    assert(t >= 1);
`
`    if (n <= BASE_LENGTH || t == 1)
`        seq_quicksort(n, data);
`    else {
`        int pivot;
`        void (*statement[2])(block_args *args);
`        block_args args;
`http://users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`3/4
`
`3
`
`

`
`10/19/2015
`        int error_code;
`
`users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`        partition(n, data, &pivot);
`        statement[0] = statement_0;
`        statement[1] = statement_1;
`        args.n = n; args.t = t; args.pivot = pivot; args.data = data;
`        error_code = sthread_block(
`            2, (void (**)(void *)) statement, (void *) &args,
`            STHREAD_MAPPING_SIMPLE, 0,
`            STHREAD_PRIORITY_PARENT, STHREAD_STACK_SIZE_DEFAULT);
`        handle_sthread_error(error_code);
`    }
`
`} /
`
`*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐*/
`
`http://users.cms.caltech.edu/~cs284/programs/quicksort/quicksort.c
`
`4/4
`
`4

This document is available on Docket Alarm but you must sign up to view it.


Or .

Accessing this document will incur an additional charge of $.

After purchase, you can access this document again without charge.

Accept $ Charge
throbber

Still Working On It

This document is taking longer than usual to download. This can happen if we need to contact the court directly to obtain the document and their servers are running slowly.

Give it another minute or two to complete, and then try the refresh button.

throbber

A few More Minutes ... Still Working

It can take up to 5 minutes for us to download a document if the court servers are running slowly.

Thank you for your continued patience.

This document could not be displayed.

We could not find this document within its docket. Please go back to the docket page and check the link. If that does not work, go back to the docket and refresh it to pull the newest information.

Your account does not support viewing this document.

You need a Paid Account to view this document. Click here to change your account type.

Your account does not support viewing this document.

Set your membership status to view this document.

With a Docket Alarm membership, you'll get a whole lot more, including:

  • Up-to-date information for this case.
  • Email alerts whenever there is an update.
  • Full text search for other cases.
  • Get email alerts whenever a new case matches your search.

Become a Member

One Moment Please

The filing “” is large (MB) and is being downloaded.

Please refresh this page in a few minutes to see if the filing has been downloaded. The filing will also be emailed to you when the download completes.

Your document is on its way!

If you do not receive the document in five minutes, contact support at support@docketalarm.com.

Sealed Document

We are unable to display this document, it may be under a court ordered seal.

If you have proper credentials to access the file, you may proceed directly to the court's system using your government issued username and password.


Access Government Site

We are redirecting you
to a mobile optimized page.





Document Unreadable or Corrupt

Refresh this Document
Go to the Docket

We are unable to display this document.

Refresh this Document
Go to the Docket